I make the following JQuery(v1.5.1) Ajax call:
function testAjaxCall()
{
$.ajax(
{
url: "/Search.ashx?",
dataType: "json"
});
}
This call returns the following JSON result:
{ "objectData" : "100" }
But in IE9 it fails with the following error (it works fine in other browsers):
SCRIPT1004: Expected ‘;’
debug.finance.com, line 1 character 16
If I remove the dataType:json parameter, the call succeeds. Any idea what is wrong? I assume my JSON is incorrect, but I passed it through a validator and it did not report any errors.
Please help!
EDIT: (more detail)
I output JSON from the server in an ASP.NET HTTP Handler as follows:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.Write("{ \"objectData\" : \"100\" }");
return;
}
I figured out what the problem was thanks to this (slightly unrelated) post: jQuery 1.5 AJAX call fails with "invalid label" for JSON requests
The culprit was jquery.validate which was not 100% compatible with JQuery v1.5. As soon as I deleted it IE9 works perfectly!
I upgraded to jquery.validate v1.8 and everything is working beautifully now.