homehttp 2016-10-07
① AJAX实现步骤

② XMLHttpRequest 对象

③ XMLHttpRequest对象的属性

④ XMLHttpRequest对象的方法

⑤ 使用AJAX发送请求及处理响应

⑥ GET请求和POST请求的区别

⑦ 文本和XML方式响应的区别

//创建XMLHttpRequestc对象
var  xmlHttp=false;
function createXMLHttpRequest(){
  if(window.ActiveXObject){//IE浏览器
    try{
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
      try{
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }catch(e){}
    }
  }else if(window.XMLHttpRequest) {//其他浏览器:如mozilla 的 fireFox 或者 netscape 7
    xmlHttp=new XMLHttpRequest();
    if(xmlHttp.overrideMimeType) {
      xmlHttp.overrideMimeType("text/html");
    }
  }
}
function processResponse(){
  if(xmlHttp.readyState==4){
    if(xmlHttp.status==200){
      var info=xmlHttp.responseText;
//      var info=xmlHttp.responseXML;
    }else{
      alert("你所请求的页面有异常。");
    }
  }else {
    //div.innerText="sending data..."
  }
}
function sendRequest(url){
  createXMLHttpRequest();
  xmlHttp.open("POST",url,true);
  xmlHttp.onreadystatechange=processResponse;
//  xmlHttp.send(null);
  xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
  xmlHttp.send("username=XXXXX&password=XXXXX&other=XXXX");
} 结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo
本文实例讲述了php+ ajax 实现的写入数据库操作。分享给大家供大家参考,具体如下:。<input class="tel" type="text" placeholder="请输入您的手机号码&q