I think I have read every * 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.
我想我已经阅读了这个问题上的每个*和google结果,它们似乎都引用了第一个jquery自动完成插件而不是当前的jquery ui自动完成。
What is the method for forcing the autocomplete results to update from the data source instead of the cached list?
强制自动完成结果从数据源而不是缓存列表更新的方法是什么?
1 个解决方案
#1
22
The jquery ui autocomplete does not do any caching. The caching is happening at the browser level. To prevent it from happening, use $.ajaxSetup
.
jquery ui autocomplete不执行任何缓存。缓存发生在浏览器级别。要防止它发生,请使用$ .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选项提供一个函数,该函数使用cache执行ajax请求:如果您不想全局禁用缓存,则返回false。
source: function(request, response) {
$.ajax({
url: "url.php",
dataType: "json",
cache: false,
type: "get",
data: { term: request.term }
}).done(function(data) {
response(data);
});
}
#1
22
The jquery ui autocomplete does not do any caching. The caching is happening at the browser level. To prevent it from happening, use $.ajaxSetup
.
jquery ui autocomplete不执行任何缓存。缓存发生在浏览器级别。要防止它发生,请使用$ .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选项提供一个函数,该函数使用cache执行ajax请求:如果您不想全局禁用缓存,则返回false。
source: function(request, response) {
$.ajax({
url: "url.php",
dataType: "json",
cache: false,
type: "get",
data: { term: request.term }
}).done(function(data) {
response(data);
});
}