In my firebug I see the server respond with:
{"status":"Results Found","errorcode":"0","result":[{"name":"test","id":"1"},{"name":"some","id":"2"}]}
When I do the following I get a "o is null" error.
$.ajax({
type: "get",
url: "http://someurl",
data: $("#eventsearch").serialize(),
dataType: 'json',
success: function(msg){
var o = $.parseJSON(msg); //o is NULL error
}
However when I do parseURL on the same string but not as a server response everything is good. What is going on here?
var t = '{"status":"Results Found","errorcode":"0","result":[{"name":"test","id":"1"},{"name":"some","id":"2"}]}';
var o = $.parseJSON(t); //everything is good here
when you set the
dataType:jsonthe json is already parsed you don’t have to dovar o = $.parseJSON(msg);you can do