我已经安装了一个应用程序,它在Opera和Firefox上运行得非常棒,但是在Google Chrome浏览器中缓存了AJAX请求,并且会显示过时的数据!阻止Chrome缓存AJAX请求
http://gapps.qk.com.au是应用程序。在Chrome中运行时,它甚至不会发送AJAX请求,但在其他浏览器中尝试时,它始终会执行AJAX请求并返回数据。
是否有任何方法(Apache/PHP/HTML/JS)阻止Chrome执行此操作?
的AJAX调用:
function sendAjax(action,domain,idelement) {
//Create the variables
var xmlhttp,
tmp,
params = "action=" + action
+ "&domain=" + encodeURIComponent(domain)
xmlhttp = new XMLHttpRequest();
//Check to see if AJAX request has been sent
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
$('#'+idelement).html(xmlhttp.responseText);
}
};
xmlhttp.open("GET", "ajax.php?"+params, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//console.log(params);
xmlhttp.send(params);
}
sendAjax('gapps','example.com','gapps');
什么是PHP脚本返回的头文件?确保他们不允许缓存,并返回适当的内容类型。 – mariusnn 2012-07-13 03:30:48