June 22, 2010
For anyone who has an application built on one hundred Ajax requests every five seconds.
jQuery:
$(function () {
$.ajaxSetup({ cache: false });
});
I’d like to believe that does something, like slow down the pain
.
What do you think?
February 26, 2009
If you are having issues when making getJson calls in jquery in the same session it is because your browser is caching your call.
function fireJsonCall(){
$.ajaxSetup({ cache: false });
$.getJSON('page?id=1' , function(data) {...});
$.ajaxSetup({ cache: true });
}
The solution, is by turning caching off using ajaxSetup prior to your call.
Ok, so this might look like a hack, and mostly it really is but it’s simple right? What I recommend doing instead is something like this:
function fireJsonCall(){
$.ajax({
url: 'page?id=1',
cache: false,
async: true,
dataType: "json",
success: function(data){...}
});
}
There I hope that, that this fix your problems.
What do you think?