0
我有以下的AJAX脚本(包括chat.php和onload=online()
在<body>
index.php),它显示了在线用户,并且在Firefox和Chrome中运行良好,但是当我尝试登录与IE8脚本不起作用。ajax脚本聊天用户bug即
任何人都可以帮我解决这个问题吗?也许AJAX脚本错误或与IE不兼容?
function online(){
if (window.XMLHttpRequest){
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else{
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
document.getElementById("online").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","proses-chat.php");
xmlhttp.send();
setTimeout("online()", 8000);
}
function autofocus(){
document.form_login.elements['username'].focus();
}
什么是错误,打F12,并期待在脚本/控制台。也强烈建议所有Ajax使用jQuery – mplungjan
我同意mplungjan。以这种方式做你的AJAX是非常灰心的。看看http://api.jquery.com/category/ajax/ – IvanL
也许这有助于:http://answers.microsoft.com/en-us/ie/forum/ie8-windows_7/xmlhttponreadystatechange-not-working -in -internet/e5aebea9-b1b3-48da-87f6-8c44e2731270?msgId = 85c6493a-8781-4722-b176-efc89a9ea7d8 显然,如果你收到一些非ascii字符,它会中断ie,所以你可能想尝试POST的GET。 – 2012-11-26 15:23:50