I have a small problem that I don\'t know how to deal with.
I\'ve written some jQuery post/gets which work fine in FF, Opera and Chrome. But when run from explorer (any
Try setting the cache: false
parameter to your AJAX requests as browsers might cache GET requests:
$.ajax({
url: '/foo',
type: 'GET',
cache: false,
success: function(result) {
// TODO: update the DOM with the results
}
});
$.ajax({
type: 'GET',
cache: false,
this is works when writing cache: false
, works in internet explorer with version 10 and 11 also in firefox and crome. Thank you stack overflow.
What is happening is that you’re likely making a GET request to a web service for your AJAX call.
Internet Explorer, in its wisdom, will automatically cache responses from GET requests while other browsers will let you decide if you’d like to cache the result or not. Once IE has successfully made a GET request, it will no longer even make that AJAX call until the cache expires on that object. The solutions are:
Use POST: One option is to simply use POST requests instead of GET requests in your application. It’s usually a minor change to switch over from GET to POST on both the client and server side.
Response Headers:
You can also prevent caching by sending additional headers along with your response. By specifying the “Cache-Control”
header with a value of “no-cache,no-store”
and returning it with the web service response you can instruct the browser not to cache the result.
jQuery:
Finally, if you’re using jQuery, you can specify that you don’t want to cache the response from your AJAX requests either across the board using the $.ajaxSetup() method or on a per request basis as cache:false.
In IE using ajax call its create cache and store this old values.when you receive the response its put catch value.so you can make cache as false.
$.ajaxSetup({ cache: false });
OR
$.ajax({ url: your need url,
cache: false,
type: 'get',
data:'your parameters',
success: function(result) {
//put your code here...
}
});
you can use both in your code.but first answer is best.
Try to add the following to the response header and the IE will not cache again:
response.addHeader("Pragma", "no-cache");
response.addHeader("Cache-Control", "no-cache");
response.addHeader("Cache-Control", "no-store");
response.addHeader("Cache-Control", "must-revalidate");
response.addHeader("Cache-Control", "Post-Check=0");
response.addHeader("Cache-Control", "Pre-Check=0");
response.addHeader("Expires", "Mon, 1 Jan 2006 05:00:00 GMT");//in the past
NOTE: the code is java code