1 回答

TA貢獻1818條經驗 獲得超3個贊
你看一下_req.open(Method,Url,IsAsync);括號里的值是否是正確
改改吧!你的代碼我這不可以執行
//根據瀏覽器類型的不同,創建不同的XmlHttpRequest
function createXmlHttpRequest()
{
//判斷瀏覽器是IE瀏覽器還是火狐瀏覽器
if(window.ActiveXObject)
{
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}else
{
xmlHttpRequest = new XMLHttpRequest();
}
}
function inits()
{
var url = ""; //指定路徑
createXmlHttpRequest();//調用創建xmlHttpRequest這個對象的函數
xmlHttpRequest.onreadystatechange=callback2;//設置回調函數
xmlHttpRequest.open("POST",url,true);//打開對象,第一個參數,為提交方式;第二個提交的路徑;第三個是否異步
xmlHttpRequest.setRequestHeader("If-Modified-Since","0");
xmlHttpRequest.setRequestHeader("Cache-Control","no-cache");
xmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttpRequest.send(null);
}
//回調函數
var arr=new Array();
function callback2()
{
if(xmlHttpRequest.readyState==4&&xmlHttpRequest.status==200)
{
var result=xmlHttpRequest.responseText;
//result為返回的值
}
}
如果你還要從外界傳值過來的話就放inits(值1,值2,......)
添加回答
舉報