开发者

jQuery: Why isn't IE8 sending a request during this call to .load()?

I am trying to make use of the hash symbol to enable back-button and refresh functionality in my AJAX web app.

In Firefox and Chrome when I click refresh the browser reloads everything properly and when the script below is run a new request is made using the URL that appears after the # sign.

In IE8 the request is never made during a refresh, however the alert pops up as if it has! I can reproduce this behavior in this simplified HTML document which I posted here:

Full HTML Doc http://pastebin.com/CVySwtup

Sample Code

$(document).ready(function () {
    // 1. AJAX history & back button
    $(window).bind("hashchange", function (e) {
 开发者_开发百科       if (!ignoreHashChange) {
            // Load content
            $("#content").load(location.hash.substring(1), function () {
                alert("content loaded!");
            });
        }
        ignoreHashChange = false;
    });

    // 2. Home page / refresh action
    if (location.hash) {
        $(window).trigger("hashchange");
    } else {
        location.hash = "Customers/List";
    }
});

edit: same behavior in IE8 when using $.get()


IE is probably reading the content from its local cache. See jQuery's .load() not working in IE - but fine in Firefox, Chrome and Safari for details and workarounds.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜