Santhosh
Santhosh

Reputation: 20406

how to clear the ajax cache in ie

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

Upvotes: 1

Views: 17094

Answers (4)

saikumar yadav
saikumar yadav

Reputation: 11

<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.

Upvotes: 1

Kimmo Puputti
Kimmo Puputti

Reputation: 256

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();

Upvotes: 5

Ilya Khaprov
Ilya Khaprov

Reputation: 2524

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

Upvotes: 7

Greg
Greg

Reputation: 321578

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});

Upvotes: 0

Related Questions