if (xmlHttp.readyState==4){
s=xmlHttp.responseText;
var obj=document.getElementById(這是變數);
if(xmlHttp.status==200){
obj.innerHTML=s;
}
}
xmlhttp.open('GET',url,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
var obj = document.getElementById(div);
if(xmlhttp.responseText!=''){
obj.innerHTML=xmlhttp.responseText;
}
}else{
alert(xmlhttp.status);
}
}
};
xmlhttp.send(null);function catchResult(){
if (xmlHttp.readyState==4){
s=xmlHttp.responseText;
var obj=document.getElementById('divID');
if(xmlHttp.status==200){
obj.innerHTML=s;
}
}
}
咦?回應不能用code....
function sendRequest(){
var form = document.login;
createXHR();
var url='login-ajax.php?ts='+new Date().getTime();
xmlhttp.open('POST',url,true);
xmlhttp.onreadystatechange = catchResult;
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send(getFormValue(form));
}
function catchResult(){
if (xmlHttp.readyState==4){
s=xmlHttp.responseText;
var obj=document.getElementById('main-login');
if(xmlHttp.status==200){
obj.innerHTML=s;
}
}
}
function sendRequest(div,url,FormID){
url+='&ts='+new Date().getTime();
createXHR();
xmlhttp.open('POST',url,true);
xmlhttp.onreadystatechange = catchResult(div);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send(getFormValue(document.getElementById(FormID)));
}
function catchResult(div){
if (xmlhttp.readyState==4){
s=xmlhttp.responseText;
var obj=document.getElementById(div);
if(xmlHttp.status==200){
obj.innerHTML=s;
}
}
}
又重試了一次 結果可以....到底是怎樣(翻桌)
30秒找到問題所在...orz