开发者

jQuery Autocomplete cache's after selecting?

So I came up with this script that ajax calls google's suggestions and JSONP returns the search results. With help from Decad I managed to implement Autocomplete but it appears tha开发者_如何学Got I'm stuck on a minor problem which I've been trying hard to solve.

When ever I type a letter I get few results, if I select one of those results and rewrite another letter, I get results of the previous selection. It's like its cached.

Here is the a working fiddle: http://jsfiddle.net/WUcpC/1/ and here is a preview of my problem: http://www.screenr.com/DKBs

Any suggestions and help is appreciated. Thanks alot


Internet Explorer always caches AJAX calls, while other browsers behave differently. So we’d better tell the browser explicitly whether or not AJAX should be cached. With jQuery, we can accomplish this simply by typing:

Try :

 $.ajaxSetup ({  
     cache: false  
 });


If you are using IE, it might be that IE caches the GET requests. Even if you explicitly set the cache value to false. try adding a nocache parametr:

 var noCache = new Date().getTime();

then add it to the url

url: 'http://suggestqueries.google.com/complete/search?qu=' + encodeURIComponent($('#q').val())+'&nocache='+noCache, 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜