- function createXMLHttpRequest(){
- if(window.XMLHttpRequest){ //Mozilla
- XMLHttpReq=new XMLHttpRequest();
- }
- else if(window.ActiveXObject){
- try{
- XMLHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
- }catch(e){
- try{
- XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
- }catch(e){}
- }
- }
- }
- //发送请求函数
- function send(url){
- appendDiv("Loading.....!");
- createXMLHttpRequest();
- XMLHttpReq.open("get",url,true);
- XMLHttpReq.onreadystatechange=proce; //指定响应的函数
- XMLHttpReq.send(null); //发送请求
- }
- function proce(){
- if(XMLHttpReq.readyState==4){ //对象状态
- if(XMLHttpReq.status==200){//信息已成功返回,开始处理信息
- var xmlDoc=XMLHttpReq.responseText;
- document.write(xmlDoc);
- }else{
- }}}
- //增加div显示Loading字样
- function appendDiv (message) {
- var div = document.createElement("DIV");
- div.align="center";
- div.style.fontSize="24px";
- div.style.margin="15%";
- var messageNode = document.createTextNode(message);
- div.appendChild(messageNode);
- document.body.innerHTML="";
- document.body.appendChild(div);}
- onload=send;