从缓存结果中删除自动完成功能
我有以下问题。我曾经有一个带有自动完成功能的输入,我最近从该字段中删除了它(因为它不再是必要的)。
该字段现在为: 没什么特别的吧?
我有另一个自动完成字段,其中填充了有关城市的信息。
var elements = $('input.auto_plaatsnaam');
elements.each(function() {
$(this).autocomplete( {
dataType: "json",
source: "/common/ajax/citysearch.php",
minLength: 1,
cache: false,
delay: 100
});
});
问题如下:某些用户在第一个(标题)输入字段上获得自动完成功能。我认为这是一个缓存问题,因为删除缓存可以解决问题。我可以在加载字段之前强制使用 php 或 js 刷新缓存吗?删除所有缓存对网站来说并不是真正有益,所以我希望我可以删除这些字段的缓存。
I've the following problem. I used to have an input with auto-completion, I removed this just recently from the field (as it was no longer necassery).
The field is now: <input type="text" class="required text motivationname valid" maxlength="30" onblur="isDoubleMotivation(this.value);" value="" id="title" name="title">
nothing special right?
I've another auto-completion field which gets filled with information about cities.
var elements = $('input.auto_plaatsnaam');
elements.each(function() {
$(this).autocomplete( {
dataType: "json",
source: "/common/ajax/citysearch.php",
minLength: 1,
cache: false,
delay: 100
});
});
The problem is as follows: some users get the auto-complete on the first (title) input field. I'm thinking it's a cache problem as removing the cache solves the problem. Can I force with php or js to flush the cache before the field is loaded? Removing all caches is not really beneficial to the site so I'm hoping I just could remove the caching of these fields.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看来更新版本的 jquery ui 的更新已经解决了这个问题。谢谢大家!
It seems an update of a more recent version of jquery ui has solved the problem. Thanks all!
一个可靠的解决方案是向查询 URL 添加一个参数,其中包含时间戳。
示例(未实际测试):
这样,AJAX 调用的 url 始终不同,因此浏览器不会进行缓存。
A robust solution is to a add a parameter to your query url, containing the timestamp.
Example (not actually tested) :
This way, the url for the AJAX call is always different, so no cache is made by the browser.
假设您将 js 保存在文件“myjs.js”中,您可以将相应的脚本标记修改为此
Assuming that you keep your js in file 'myjs.js' you can modify corresponding script tag to this