清除jquery ui自动完成的缓存 [英] Clear the cache for jquery ui autocomplete
问题描述
我想我已经阅读了有关此问题的所有stackoverflow和google结果,它们似乎都引用了第一个jquery自动完成插件,而不是当前的jquery ui自动完成插件.
I think I have read every stackoverflow and google result available on this issue and they all seem to refer to the first jquery autocomplete plugin and not the current jquery ui autocomplete.
什么是强制自动完成结果从数据源而不是从缓存列表更新的方法?
What is the method for forcing the autocomplete results to update from the data source instead of the cached list?
推荐答案
jquery ui自动完成功能不进行任何缓存.缓存发生在浏览器级别.为防止发生这种情况,请使用$.ajaxSetup
.
The jquery ui autocomplete does not do any caching. The caching is happening at the browser level. To prevent it from happening, use $.ajaxSetup
.
$.ajaxSetup({ cache: false });
如果您不想全局禁用缓存,您还可以向
You could also instead supply a function to the source option that does the ajax request for you with cache: false
if you don't want to disable caching globally.
source: function(request, response) {
$.ajax({
url: "url.php",
dataType: "json",
cache: false,
type: "get",
data: { term: request.term }
}).done(function(data) {
response(data);
});
}
这篇关于清除jquery ui自动完成的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!