var ajax;
function showHint()
{ var username = document.getElementById(Lusername).value;
ajax=GetXmlHttpObject();
if (ajax === null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="./script/php/determine.php?sendUsername="+username;
ajax.onreadystatechange=stateChanged ;
ajax.open("GET",url,true);
ajax.send(null);
}
function stateChanged()
{
if (ajax.readyState === 4 && ajax.readyState === 200)
{alert(ajax.responseText);}
}
function GetXmlHttpObject()
{
var ajax=null;
try{ajax=new XMLHttpRequest();}
catch (e)
{ try{ajax=new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){ajax=new ActiveXObject("Microsoft.XMLHTTP");}
}
return ajax;
}
PHP
Ajax
------解决方案--------------------
function stateChanged()
{
if (ajax.readyState === 4){
alert(ajax.responseText);
}
}
回调改这样看输出什么
//var url="./script/php/determine.php?sendUsername="+username;
//==>url改成绝对路径,./这种比较少见。。
var url="/script/php/determine.php?sendUsername="+username+'&_dc='+new Date().getTime();//加个时间戳防止ie下get缓存
get提交的,注意要使用$_GET["sendUsername"]来获取,不能使用$_POST
------解决方案--------------------
if (ajax.readyState === 4 && ajax.status === 200)