空XmlHttp响应文本(仅限Google Chrome) [英] Empty XmlHttp responsetext (only Google Chrome)
本文介绍了空XmlHttp响应文本(仅限Google Chrome)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的Google Chrome聊天脚本存在问题。
有时候,在你重新加载页面之前,responsetext是空的,但有时它运行良好。它每秒打开一个xmlhttp连接,如果第一个好,那之后的那个也很好。
在Firefox中,它总是很好。
I have a problem with my chat script in Google Chrome. Sometimes the responsetext is empty until you reload the page, but sometimes it's working well. It opens a xmlhttp connection every second and if the first good the ones after that also good. In Firefox it's always good.
var url = "text.php";
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = myfunc;
xmlHttp.send(null);
function myfunc()
{
if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
{
var msg = xmlHttp.responseText;
alert(msg);
}
}
推荐答案
尝试这个
var xmlHttp;
xmlHttp=new XMLHttpRequest();
var url = "text.php";
xmlHttp.onreadystatechange = function()
{
if (xmlHttp.readyState==4 && xmlHttp.status==200)
{
var msg = xmlHttp.responseText;
alert(msg);
}
}
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
这篇关于空XmlHttp响应文本(仅限Google Chrome)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文