how to clear the ajax cache in ie

2019-04-02 09:53发布

I'm using jquery ajax, how to clear the cache of the ajax result?

4条回答
放荡不羁爱自由
2楼-- · 2019-04-02 10:34

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

查看更多
相关推荐>>
3楼-- · 2019-04-02 10:42

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});
查看更多
走好不送
4楼-- · 2019-04-02 10:43

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();
查看更多
Emotional °昔
5楼-- · 2019-04-02 10:53
<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.

查看更多
登录 后发表回答