开发者

jQuery.Load() not working right in IE9

On the home page of my site, jquery.load() is ran at $(document).ready(), and requests a URL something like:

"/ajax/Listings.aspx?pageindex=0"

When this page is ran, in the Page_Load() a ListView is bound to a DataSet which returns some products to appear. If there are no items, then the EmptyDataTemplate displays something like:

"There are开发者_高级运维 currently no products"

In my system, there is 1 product that should be displayed. In FireFox, this is returned and displayed on the page correctly.

However, in Internet Explorer the EmptyDataTemplate is displayed. Furthermore, if the URL ("/ajax/Listings.aspx?pageindex=0") is opened up in the IE9 browser (as a fresh tab), then this returns 1 product.

Why does IE9 not bind any items to the ListView when jQuery.Load() is used?


While appending random strings to the URL works, the best approach to handle this is to disable the cache:

$.ajaxSetup ({
    // Disable caching of AJAX responses
    cache: false
});

Taken from here


Shortly after posting this I went back to try and see if I can work it out myself, and believe I've found the solution!

Because I'd opened the ajax page in a seperate tab, when I went back to the home page, this was now being shown.

Therefore, I believe this is cached, and the only way to refresh the cache is to open it in a new tab.

So, I've added a random string to the end of the URL to ensure it doesn't cache the page each time:

function random_string() { return String((new Date()).getTime()).replace(/\D/gi, '') }

var url = "/ajax/Listings.aspx?pageindex=0&rnd=" + random_string
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜