开发者

Sudden IE8 load() problem

Suddenly this week my IE8 users started complaining that certain load() requests 开发者_运维百科were not loading correctly. No change in code, and just with IE8 - FireFox 3 & 4, Chrome latest and IE9 RC all work fine.

Here is the code:

$("#"+div).empty().html('<center><img src="ajax-loader.gif" /></center>');
$("#"+div).load(url);

We load a 'loading' gif (which IE8 users see just fine), and then load the url into the div. IE8 users don't get any errors, they just get a blank screen. The loading gif goes away and there is nothing in the div. url does have a random # attached to avoid caching, and the funny thing is load() is working just fine for them in other spots of the app.

Thoughts?


Ensure that the server script you are calling sends proper HTML and it doesn't throw any errors. Also you may try like this:

// To prevent the need of manually adding random #
$.ajaxSetup({ cache: false });

$('#' + div)
    .html(
        $('<center/>', {
            html: $('<img/>', {
                src: 'ajax-loader.gif',
                alt: 'loading...'
            })   
        })
    )
    .load('/foo');

Live demo (working under IE8).


This turned out to be some bad <script> code on the page that was working fine in every browser except IE8 (was fine in IE7 and IE9 too). I removed the <script> and the rest of the page worked just fine.

I used IETester to test all the IE versions. Hope this helps someone else.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜