在IE9 AJAX的问题? [英] AJAX problem in IE9?
本文介绍了在IE9 AJAX的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经做了AJAX的聊天室;和它的作品在Chrome和FF,但当然,不是在IE浏览器。这是我的code:
I have made an AJAX chatroom; and it works in chrome and FF, but of course, not in IE. Here's my code:
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(){
var ajaxRequest;
try {
ajaxRequest = new XMLHttpRequest();
} catch (e) {
try {
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4) {
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
ajaxRequest.open("GET", "pull.php", true);
ajaxRequest.send(null);
}
setInterval( "ajaxFunction()", 1000 );
//-->
</script>
的结果不会显示。我有一个名为AjaxDiv格有没有什么帮助任何人。我究竟做错了什么?这是一个错误?
The result never displays. I have a div named AjaxDiv if that helps anyone. What am I doing wrong? Is this a bug?
推荐答案
每次大概唬弄了缓存副本你提出要求。
Probably yanking out a cached copy every time you make a request.
无论是设置正确的缓存头在服务器上
Either set the correct caching headers on the server
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Pragma: no-cache' );
或追加一个查询字符串,如GET请求以下
Or append a query string to the get request like the following
ajaxRequest.open("GET", "pull.php?ts=" + new Date().getTime(), true);
这篇关于在IE9 AJAX的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文