Hi,
I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax()
To perform the AJAX I'm using:
$.ajax({
url: myUrl,
cache: false,
dataType: "json",
success: function(data){
...
},
error: function(e, xhr){
...
}
});
And if I return an array of items then it works fine:
[ { title: "One", key: "1" }, { title: "Two", key: "2" } ]
The success function is called and receives the correct object.
However, when I'm trying to return a single object:
{ title: "One", key: "1" }
The error function is called and xhr contains 'parsererror'. I've tried wrapping the JSON in parenthesis on the server before sending it down the wire, but it makes no difference. Yet if I paste the content into a string in Javascript and then use the eval() function, it evaluates it perfectly.
Any ideas what I'm doing wrong?
Anthony