ajax基本js

来源:互联网 发布:淘宝佣金平台 编辑:程序博客网 时间:2024/06/07 04:36

 var xmlHttp;
  function createXmlHttp(){
     if (window.ActiveXObject){
      xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
      if (xmlHttp == null){
       xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
      }
     } else {
      xmlHttp = new XMLHttpRequest();
     } 
  }
  function postMessage(url,content,callback){
   createXmlHttp();
     xmlHttp.open('post',url);
     xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
     xmlHttp.onreadystatechange=callback;
     xmlHttp.send(content); 
  } 

原创粉丝点击