Ajax registration Verification, today this article is a bit strange, is to verify that the URL can be normal access Oh,
<tr>
<TD height= "align=" "Center" > Blog Address:</td>
<TD height= "align=" "Center" ><span class= "STYLE1" >*</span></td>
<td><label>
<input name= "blog" type= "text" id= "blog" size= "" onblur= "Ajax (0);" />
</label></td>
<TD id= "U_info" ></td>
</tr>
The above is a simple HTML code program. The following is a PHP validation code.
if ($ta ==0) {
if (@file_get_contents ($XM)) {
Echo ' <div id= "success" > blog address can access </div> ';
}else{
Echo ' <div id= "error" > Sorry, the blog address you entered cannot be accessed normally <div > ';
}
}else{
echo "<div id= ' error ' > Sorry, invalid operation!</div>";
}
Okay, I'll just write back the anti-Ajax code,
var xmlHttp = false;
function Ajaxcreate () {
try {
XmlHttp = new ActiveXObject ("Msxml2.xmlhttp");
catch (e) {
try {
XmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");
} catch (E2) {
XmlHttp = false;
}
}
if (!xmlhttp && typeof xmlhttprequest!= ' undefined ') {
XmlHttp = new XMLHttpRequest ();
}
if (!xmlhttp) {alert (' Create xmlHttp Fail '); return false;}
}
Ajaxcreate ();
Xmvalue=document.getelementbyid ("blog"). Value;
var url= "ajax_check.php?txt=" +encodeuri (xmvalue) + "&tag=" +encodeuri (str) + "&rd=" +math.random ();
if (xmvalue== null | | xmvalue.length>200 | | | xmvalue = "") return false;
Xmlhttp.open ("POST", url,true);
Xmlhttp.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
Xmlhttp.send (Xmvalue);
Xmlhttp.onreadystatechange=returnstate;
}
function Returnstate () {
if (xmlhttp.readystate!= 4) {
document.getElementById ("U_info"). Innerhtml= "<div class=defult> is verifying please ...</div> later";
}
if (xmlhttp.readystate = = 4) {
document.getElementById ("U_info"). Innerhtml=xmlhttp.responsetext;
}
}
OK below this paragraph I have written before, but in order to facilitate or also write out, the final statement: This site original article reproduced please specify: www.111cn.net/phper/php.html