I get a parse error when using jQuery to load some JSON data. Here's a snippet of my code:
jQuery.ajax({
dataType: "json",
success: function (json)
{
jQuery.each(json, function ()
{
alert(this["columnName"]);
});
}
});
I get no errors when parsing a non-empty JSON object. So my guess is that the problem is with my serializer.
Question is: how do I format an empty JSON object which jQuery won't consider malformed?
This is what I've tried so far, with no success:
{[]}
{[null]}
{}
{null}
{"rows": []}
{"rows": null}
{"rows": {}}
UPDATE:
I can understand that I've been somewhat vague--let me try and clarify:
Parsing of the JSON object is not the issue here--JQuery is - I think.
jQuery throws a parse-error (invokes the error function). It seems like jQuery's internal JSON validation is not accepting any of the before mentioned objects. Not even the valid ones.
Output of the error function is:
XMLHttpRequest:
XMLHttpRequest readyState=4 status=200
textStatus:
parsererror
errorThrown:
undefined
This goes for all of the before mentioned objects.