Reputation: 9583
I allready have this:
$(document).ready(function() {
// one time stuff
$.ajaxSetup({
cache:false
});
}
And i now it works cause i had a problem without it and i added it for a file that i read every 100ms. Only that was for this:
$.getJSON('output.json', function(data){
faceDetected = data.faceDetected;
frameCount = data.frameCount;
});
It doesn't work for this:
function loadContent(page){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
$("#content").html(xmlhttp.responseText);
}
}
xmlhttp.open("GET", page, true);
xmlhttp.send()
}
Does someone know how to fix?
Upvotes: 0
Views: 143
Reputation: 1039418
The first example is jQuery and the cache: false
setting is only about jQuery.
The second is using the native XMLHttpRequest
object. To bust the cache in the second example you could append a timestamp and a random number to the query string.
var noCache = new Date().getTime() + Math.random() * 1234567;
xmlhttp.open("GET", page + '&noCache=' + stamp, true);
You may take a look at the following blog post for a more elaborate solution.
Upvotes: 1