0
下面的代码我用于动态更新textarea而不重新加载整个页面。XMLHTTPRequest无法正常工作
它昨天晚上工作,但今天早上我尝试使用它时停止工作。 alert(request.readyState+" "+request.status)
返回2 0
和4 0
...帮助?
<script type="text/javascript">
function init(){
var url="http://www.suchandsuch.net/ChatBowl/text.txt";
var request= new XMLHttpRequest();
request.open("GET",url,true);
request.onreadystatechange= function(){
//alert(request.readyState+" "+request.status);
if (request.readyState ==4 && request.status == 200){
document.getElementById('textarea').innerHTML=request.responseText;
}
};
request.send(null);
}
var int=self.setInterval('init()', 3000);
</script>
我真诚地感谢您的帮助。
你使用了什么浏览器? – gideon 2012-02-06 08:44:34
您是否正在使用file:///协议访问该页面?你是否在同一个域名www.suchandsuch.com下尝试页面? – fcalderan 2012-02-06 08:47:17
尝试Opera和FireFox ...我可以尝试其他人真正快速,看看他们的工作..不使用IE,所以ActiveXObject的东西不应该是一个问题吗? – moesef 2012-02-06 08:48:10