开发者

jquery ajax call fails in IE only

开发者 https://www.devze.com 2023-01-02 13:47 出处:网络
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.

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,
       开发者_如何学C     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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号