javascript - Can not get JSON object -


Hey, under this URL 1234 /? Fmt = json I'm making a Jason object like that

  surveyage = {question: $ ("# question"). Val (), Options: Option, Count: Calculation}; Var jsonString = JSON.stringify (Surveyors);   

And I'm trying to recover a json object via an AJAX call

  var url = "1234? Fmt = json"; $ .jax ({url: url, type: "get", datatype: 'jason', success: function (data) {$ ("# display"). Html (data);}});   

How can I not display data? I have tried that if I cross the data type parameter and keep the others the same, then I can in some way get the JSON string, which I do not know. And I could not help but I noticed that there are a few similar problems instead of "Post" instead of "Post", why is it that it is right? Thanks

Make sure your "callback url" 1234 /? Fmt = json only

Try hard coding values ​​for example, and see if it works, then delete the code in your URL as output to your http response and remove other stuff. Please give it. Just show the exact answer shown on this line and nothing else.

  {Question: "My question", option: "One option", count: 3}   

Change your calling code to:

  var url = "1234? Fmt = json"; $ .ajax ({url: url, success: function (data) {alerts (data); alerts (data question);}});   

If you see two warning boxes; The first one with the content of "[object object]" (this is slightly different depending on the browser) and there is a second warning with "my question", then you are off for a good start, post back and tell me and We will take it from there.

In addition, setting the "Type" attribute for "Receive" or "Post" does not make it possible to parse your response text. Http request 1234 /? Fmt = json, in a valid Jason object in the browser. Receive and have important differences in the post, but the answer to your HTTP request is nothing relevant to parse the text.

Comments