|
//定义AJAX
function createXHR()
{
var req;
if(window.ActiveXObject)
{
req = new ActiveXObject('Microsoft.XMLHTTP');
}
else
{
req = new XMLHttpRequest();
}
return req;
}
var http = createXHR();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkuser()
{
var url = "checkuser.php";
var name = document.getElementById('username');
http.open("GET",url,true);
http.onreadystatechange = deal_response;
http.send(null);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function deal_response()
{
if (http.readyState==4&&http.status==200)
{
var text = http.ResponseText;
if (http.ResponseText=='1')
{
document.getElementById('notice_user').style.background = "#ffF000";
document.getElementById('notice_user').innerHTML = text;
}
else
{
document.getElementById('notice_user').style.background = "#ff0fff";
document.getElementById('notice_user').innerHTML = text;
}
}
alert(http.ResponseText);
}
alert的结果是undefined |
|