views:

50

answers:

1

I had just about concluded that jQuery's ajax calls wouldn't work with JSON data in IE 8, no matter what I tried. I found that I could use the jQuery 1.3.2 library and this fixed the problem, but 1.4 simply would not play ball with JSON ajax requests. Even when the JSON data returned was so simple that there was no question of it being in an invalid format. For example:

{"x":"a"}

This was regardless of whether I used a Java servlet to return the JSON data, or a simple, canned text file. Regardless of dataType or contentType. Regardless of GET vs POST. Regardless of whether I used $.ajax or $.getJSON. And it all works in Firefox 3.6.

Then it dawned on me to take out the reference to Firebug Lite and IT WORKED! Suddenly the problem vanished. It worked regardless of tinkering with the contentType in the response (in the servlet that is), or of the dataType I specify in the request.

The problem returns if I link to Firebug Lite again...even if my code never actually uses it.

Has anyone seen this kind of behavior, and does anyone have a fix or workaround? I'd hate to have to stop using Firebug Lite. Thanks for any insight. Again, the problem only occurs when you combine jQuery 1.4, Firebug Lite, JSON data, and IE 8.

Here is the ajax call to a servlet, if it matters:

$.ajax({
 cache: false,
 url:"http://localhost:8080/Performance_Reporting/TestServlet",
 type:"GET",
 contentType: "application/json",
 dataType: "json",
 timeout:30000,
 success: function(d, status, req)
 {
  $("#result").text(d.x);
 },
 error: function(req, status, err)
 {
  $("#result").text(req.responseText);
 }
})
A: 

I've actually seen the same problem with plain HTML responses, too.

Leonid Shevtsov