HTML code
| The code is as follows |
Copy Code |
|
<style >
#apDiv1 {display:none; background: #FFF; border:1px solid #CCC; width:223px; padding:5px;}
</style>
<input type= "text" maxlength= "128" name= "title" id= "title" placeholder= "Enter Broker ID number" onkeyup= "getrenews (this.value);" autocomplete= "Off"/>
<ul id= "ApDiv1" style= "position:absolute;left:0px;top:24px" ></ul> |
JS Ajax code is as follows
| The code is as follows |
Copy Code |
|
function Createxmlhttprequest () {//Create XMLHttpRequest Object
if (window. ActiveXObject) {//ie
try {
return new ActiveXObject ("Microsoft.XMLHTTP");
catch (e) {
Return
}
}else if (window. XMLHttpRequest) {//mozilla,firefox
try {
return new XMLHttpRequest ();
catch (e) {
Return
}
}
}
function Getrenews (Value) {//Keynote
var xmlhttp=createxmlhttprequest ();
var url = "ajaxsend.php?title=" +value+ "&mt=" +math.random (300000);
if (value== "") {
return false;
}
if (xmlHttp) {
callback = Getreadystatehandler (xmlHttp);
Xmlhttp.onreadystatechange = callback;
Xmlhttp.open ("Get", url,true);
Xmlhttp.send (NULL);
}
}
function Getreadystatehandler (xmlHttp) {//server returns post-processing functions
return function () {
if (xmlhttp.readystate = = 4) {
if (Xmlhttp.status = = 200) {
if (Xmlhttp.responsetext) {
document.getElementById ("ApDiv1"). style.display= ' block ';
document.getElementById ("ApDiv1"). Innerhtml=xmlhttp.responsetext;
}else{
document.getElementById ("ApDiv1"). Innerhtml= "<li> Sorry, not found relative to the property!" </li> ";
}
}
}
}
}
|
The above code is in Baidu search to its own simple to modify a bit, because they used to feel the use of fast also did not use the jquery Ajax plug-ins.