I've been playing with JSON a while, and noticed something odd.

when you make a $.getJSON call, you get a nice happy object returned.
However, when calling $.post, the returned data is never evaluated.
While it is a simple task to make this into a happy little object, it
seems to me that the behavior of these two functions is confusing. It
isn't explained in the docs that the returned data in a $.getJSON call
is automatically evaluated while that of the $.post is not. Please
note that even if you specify the return type as "json" it is still
not evaluated. If you specify the type as json it seems like it should
be processed. Or at least some sort of standard across the board
should occur.

assuming that json.php returns a valid JSON object....

alert box that shows an object
$.getJSON("http://test.com/json.php";, function(data){ alert(data); })

alert box with a string of the JSON
$.post("http://teset.com/json.php";, function(data){ alert(data); },
"json")

The only things that I noted as different was that the request headers
of the $.getJSON had a content-type of "text/xml" while the $.post had
no content type.

Reply via email to