ITeye博客

ajax请求时的缓存的问题

yaofeng911 · 2009-05-05 17:35 · JQuery · Web前端 · Ajax · json · jQuery · IE · Markdown

ajax请求同一个url地址时,如果发现url地址没有变而缓存里有就会直接去取值,不会再去请求服务器。这种情况会在不同的机器不同的IE上各有不同,解决的方式是在ajax请求的地址里加上一个随机的参数例如(jQuery):

 

$.getJSON(path+"/library/structuresView.do?num=1&structCount="+customColumnNum*rowNum+"&datetime="+(new Date()).getTime(), "", function(json){alert(json)})

$.ajax({url: path+"/library/structuresPropertyPreview.do?fetch=all&random="+Math.random(),
type: 'GET', 
success: function(data){alert(data)} });

 

 

只要ajax每次请求的地址不一样就可以的。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。