Home > Backend Development > PHP Tutorial > ajax creation code_PHP tutorial

ajax creation code_PHP tutorial

WBOY
Release: 2016-07-13 16:58:48
Original
801 people have browsed it

ajax creation code

var http_request=false;
function send_request(url){//Initialization, specify processing function, function to send request
http_request=false;
//Start initializing the XMLHttpRequest object
If(window.XMLHttpRequest){//Mozilla browser
http_request=new XMLHttpRequest();
If(http_request.overrideMimeType){//Set MIME category
http_request.overrideMimeType("text/xml");
}
}
else if(window.ActiveXObject){//IE browser
Try{
http_request=new ActiveXObject("Msxml2.XMLHttp");
}catch(e){
       try{
http_request=new ActiveXobject("Microsoft.XMLHttp");
}catch(e){}
}
}
If(!http_request){//Exception, creation of object instance failed
​​window.alert("Failed to create XMLHttp object!");ajax creation code
Return false;
}
http_request.onreadystatechange=processrequest;
//Determine the request method, URL, and whether to execute the next code synchronously
http_request.open("GET",url,true);
http_request.send(null);
}
//Function to process returned information
function processrequest(){
if(http_request.readyState==4){//Determine the object status
If(http_request.status==200){//The information has been returned successfully, start processing the information
Document.getElementById(reobj).innerHTML=http_request.responseText;
}
​ else{//The page is abnormal
alert("The page you requested is not normal!"); ajax creation code
}
}
}
function dopage(obj,url){
document.getElementById(obj).innerHTML="Reading data...";
send_request(url);
reobj=obj;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631371.htmlTechArticleajax creation code var http_request=false; function send_request(url){//Initialization, specify processing function, send request Function http_request=false; //Start initializing the XMLHttpRequest object...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template