本文介绍了jQuery ajax定期调用时,在IE8上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前每2秒使用jQuery执行一次相同的Ajax请求.由于某些原因,在IE8上它只能在第一次使用.接下来的每个请求似乎都会自动转到onSuccess函数,其结果与第一个请求相同.

I am currently doing the same ajax request using jQuery every 2sec. For some reason, on IE8 it only work the first time. Each following request automatically seems to go to the onSuccess function, with the same result as the first request.

在FF3和Chrome上,相同的代码可以正常工作.

The same code work perfeclty on FF3 and Chrome.

有人知道该错误以及如何破解它吗?还是我只是做错了什么?

Is anybody aware of that bug and how to hack around it?Or am I simply doing something wrong?

推荐答案

IE具有缓存功能...它可能刚刚缓存了您的请求.确保将类似随机数的内容添加到查询字符串中,如下所示:

IE has a caching feature... it's possible that it has just cached your request. Make sure you append something like a random number to your query string, like so:

var url = "/yoururl.html";
url = url + "&random=" + Math.random();

这篇关于jQuery ajax定期调用时,在IE8上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 06:18