从缓存中阻止JQUERY .load [英] Prevent JQUERY .load from cache
问题描述
Thansk!
如果您正在使用 $。ajax
低级方法,则禁用缓存的选项在jQuery中可用。这在 load
的简化签名中没有表示。您可以通过确保URL始终是唯一的来代替它。您可以在URL的末尾以毫秒为单位放置当前时间以实现此目的,因为这实际上始终是唯一的:
url + ='?_ ='+(new Date())。getTime();
(这假定 url
是一个字符串包含请求URL,并且当前没有任何查询参数。)
It seems that in IE9, using jquery .load will pull data from the browsers cache and so the 'real time' effect of AJAX loading content isnt working. Is there any kind of switch to force jquery .load to get the data fresh?
Thansk!
The option to disable caching is available in jQuery if you are using the $.ajax
low-level method. This is not represented in the simplified signature for load
. You could mimic it instead, by ensuring that the URL is always unique. You can put the current time in milliseconds on the end of the URL to achieve that, since that will practically always be unique:
url += '?_=' + (new Date()).getTime();
(This presumes that url
is a string containing the request URL and that it doesn't have any query parameters currently.)
这篇关于从缓存中阻止JQUERY .load的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!