I\'ve tried to parse the following json response with both the JQuery getJSON and ajax:
[{\"iId\":\"1\",\"heading\":\"Management Services\",\"body\":\"
The JSON string you have is an array with 1 object inside of it, so to access the object you have to access the array first. With a json.php that looks like this:
[
{
"iId": "1",
"heading": "Management Services",
"body": "Program Overview
January 29, 2009
"
}
]
I just tried this
$.getJSON("json.php", function(json) {
alert(json[0].body); // Program Overview
January 29, 2009
alert(json[0].heading); // "Management Services"
alert(json[0].iId); // "1"
});
I also tried this:
$.get("json.php", function(data){
json = eval(data);
alert(json[0].body); // Program Overview
January 29, 2009
alert(json[0].heading); // "Management Services"
alert(json[0].iId); // "1"
});
And they both worked fine for me.