清除jquery ui自动完成的缓存 [英] Clear the cache for jquery ui autocomplete

查看:182
本文介绍了清除jquery ui自动完成的缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我已经阅读了有关此问题的所有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 });

如果您不想全局禁用缓存,您还可以向选项提供一个功能,该功能通过cache: false为您执行ajax请求.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆