xmlhttp.send(null);
xmlhttp.onreadystatechange = processRequest();
===>>>
xmlhttp.onreadystatechange = processRequest;
xmlhttp.send(null);
xmlhttp.onreadystatechange = processRequest();
===>>>
xmlhttp.onreadystatechange = processRequest;
xmlhttp.send(null);
var xmlhttp = false;
function init(){
window.setInterval(startRequest, 2000);
return false;
} function createXMLHttpRequest() {
if (window.ActiveXObject){
try{
xmlhttp=new ActiveXObject(\"Msxml2.XMLHTTP\");
}
catch(e){
try{
xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");
}
catch(e){}
}
} else if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
if(xmlhttp.overrideMimeType){
xmlhttp.overrideMimeType("text/xml");
}
} //异常,创建对象失败
if(!xmlhttp){
window.alert("不能创建XMLHttpRequest对象实例!");
return false;
}
}
function startRequest() {
var url = "myurl";
createXMLHttpRequest();
xmlhttp.open("GET", url, false);
if (navigator.userAgent.indexOf(\"MSIE\") != -1) {
xmlhttp.onreadystatechange = processRequest; //IE
} else {
xmlhttp.onreadystatechange = processRequest(); //Netscape FF
}
xmlhttp.send(null);
} function processRequest() {
alert("readyState:"+xmlhttp.readyState+""); //得到的总是1!!
if (xmlhttp.readyState == 4){
if (xmlhttp.status == 200){
feedlist();
}
}
}
function feedlist() {
var xmlString = xmlhttp.responseText;
document.getElementById("show_area").innerHTML = xmlString;
}
</script >
xmlhttp.open("GET", url, false);
==>
xmlhttp.open("GET", url, true);
试试
function getXMLHttpRequest(){
var XMLHttpReq = false;
if(window.XMLHttpRequest){
XMLHttpReq=new XMLHttpRequest();
}
else if(window.ActiveXObject){
try{
XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){/*failed*/alert('创建控件失败,请升级你的浏览器');}
}
}
getXMLHttpRequest = XMLHttpReq;
}
function getXMLHttpRequest(){
var XMLHttpReq = false;
if(window.XMLHttpRequest){
XMLHttpReq=new XMLHttpRequest();
}
else if(window.ActiveXObject){
try{
XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){/*failed*/alert('创建控件失败,请升级你的浏览器');}
}
}
return XMLHttpReq;
}
if (navigator.userAgent.indexOf(\"MSIE\") != -1) {
xmlhttp.onreadystatechange = processRequest; //IE
} else {
xmlhttp.onreadystatechange = processRequest(); //Netscape FF
}
倒数第三行else前的半个大括号为什么用全角的?
还在看其他有没有问题
发现该问题不是你代码的问题,不少人都遇到这样的问题。我测试后的感觉该问题是由于MF的onreadystatechange只会执行一次,无论你将它放在什么地方都是如此:有只出现0、只出现4的
如果你有意可将此贴发送到MF官网论坛上,本人也十分该问题。继续观望中