3

This ajax request checks if a TIF file exists in a certain directory and either sets a button to open the file or to display an error message if it isn't there.

        $.ajax(
        {
            cache: false,
            url: directory,
            success: function() { $("#img" + row).click(function() { window.location.href = directory; return false; }) },
            error: function(data) { alert(data.responseText); $("#img" + row).click(function() { $("#ImageDialog").dialog("open"); return false; }) }
        });

Sometimes, but not always, IE8 will return a failure even when the file exists and FF and Chrome return successes. I added the "alert(data.responseText)" trying to debug the problem, but I do not ever get the alert box. IE instead fails throwing a "System error: -1072896748".

What is going on?

wham12
  • 295
  • 5
  • 21
  • I have this error, but *do* get an error, only no line # in debug. only "TypeError object not initialized or invisible" thanks IE... – Talvi Watia Sep 07 '10 at 10:09

2 Answers2

0

It might have something to do with encoding problems (your content being in another charset than it promises). See http://keelypavan.blogspot.com/2006/07/system-error-1072896658-in-ie.html.

MvanGeest
  • 9,536
  • 4
  • 41
  • 41
  • Is there any way to determine what charset is getting returned? If I do just alert(data) I get [object]. I tried setting the contentType to charset=utf-8, and that did not stop it from throwing the system error. – wham12 Jun 04 '10 at 18:57
  • You could try using Firebug in Firefox. But setting the contentType is no use if what you return is not *actually* UTF-8... the problem could be that the browser interprets it as UTF-8 with or without the contentType set, but the charset is actually something incompatible (though that ought to be very exotic...) – MvanGeest Jun 04 '10 at 21:49
  • The contentType getting returned should be "image/tiff"... if I put that it continues to work correctly in Firefox, but IE is failing for some reason. If I change the contentType to charset=utf-8, both IE and Firefox fail. However, in Firefox I get the alert box with the image trying to be displayed as text. In IE I continue to receive the system error failure. – wham12 Jun 07 '10 at 15:17
  • check your response headers.. e.g. `Content-Encoding:gzip Content-Type:text/javascript; charset=UTF-8` – Talvi Watia Sep 07 '10 at 10:15
0

Alright, I believe I found the cause/solution posted over here: IE not triggering jQuery Ajax success

It says that

IE appears to trigger failure if it can't parse the response as xml, even if the request was a success, so if you're requesting an image, for example, it would return a xhr.status of 200 in the error block. I stuck my "success" functionality in the success block for FF and in the error block wrapped in an "if (xhr.status == 200)" conditional.

Community
  • 1
  • 1
wham12
  • 295
  • 5
  • 21
  • is it just me, or does IE need overly excessive error-checking? – Talvi Watia Sep 07 '10 at 10:12
  • ..bizzare, but true - I found that firebug lite was actually causing IE8 to trigger "error" with status 200, removed firebug lite (script tag in HEAD) and it all works!! crazy – zack Oct 12 '10 at 13:24
  • Guys, just got a bizarre bug. Only IE was failing on AJAX, although the JSON was correctly encoded. The issue was that I forgot a little hyphen when I set up the Content-Type, it was "utf8" instead of "utf-8". Maybe this can help someone someday. – thepanuto Dec 02 '13 at 16:59