本程序已经通过本人测试通过,并且本人一直用的就是这个Ajax程序验证用户名是否存在或者检查验证码是否正确,input.php为处理数据的程序,你可以根据具体需求写成验证用户名是否存在等类型的程序,详情如下:

/******************保存为Ajax.php**********/

script language="javascript">
function getXMLHTTPRequest()
{
var xRequest=null;
if (window.XMLHttpRequest)
{
xRequest=new XMLHttpRequest();
}
else if (typeof ActiveXObject != "undefined")
{
xRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
return xRequest;
}
function Ajax(url)
{
AjaxObj = getXMLHTTPRequest();
AjaxObj.onreadystatechange = processRequest;
AjaxObj.open("post",url,true);
AjaxObj.setRequestHeader('Content-type','application/x-www-form-urlencoded');
AjaxObj.send("name"+name);

}
function processRequest()
{

if(AjaxObj.readyState == 4)
{
if(AjaxObj.status == 200)
{
if(AjaxObj.responseText != "")
{
document.getElementById("show").innerHTML="";
//alert(AjaxObj.responseText);

document.getElementById("show").innerHTML=AjaxObj.responseText;

}
}
else
{
alert("您所请求的页面有异常。")
}
}
else
{
document.getElementById("show").innerHTML="稍后......";
}
}
</script>

<input value="点击" type="button" onblur="Ajax('input.php')";>//替换这里
<div id="show"></div>



/*********************保存为input.php***************/

<?
echo iconv("GB2312","UTF-8","中文");
?>

到现在才0条评论

看完了要说点啥?

昵称

网址

电邮

打开HTML 打开UBB Emots 打开表情 隐藏 记住我 [注册]