开发者

how to clear the ajax cache in ie

I'm using jquery ajax, how to clear the cache of the开发者_如何学JAVA ajax result?


Are you looking for $.ajax cache option? http://docs.jquery.com/Ajax/jQuery.ajax#options


If you want to bypass the cache you can add some random argument to the url:

var url = 'http://example.com/ajax?' + (new Date()).getTime();


<script>
 var counter = 0;
 var counterValue = 0;

 function submitForm()
 {
       counter = counter + 1;
       counterValue = counter;
         var params = $("#DetailForm").formSerialize();
$("#DetailViewDiv").load("./shopmart/priceDetail.jsp?counterValue="+counter+"&"+params,
function(){$("#PriceTagDiv").show();});

 }
</script>

You add a counter for every request. Ajax will cache the call but as the counter increments everytime, the params to load jsp will become different.


You can't actually clear the cache as it's controlled by the browser, but you can ask for the next request not to be cached by adding cache: false to your options.

$.get('/callback/', {cache: false});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜