快速创建javascript中ajax通用函数

if( typeof XMLHttpRequeat == "undefined" )
 XMLHtppRequest = function(){
  //ie 用ActiveXObject
   //XMLHttpRequest对象
   
    return new ActiveXOject(
      navigator.userAgent.indexOf("MSIE5")>=0 ?  "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP" 
    );
};


//创建新的请求
 
var xml = new XMLHttpRequest();

//初始化请求
xml.open("GET","路径",true);

//建立连接并发送数据
xml.send();
posted @ 2010-10-05 22:32  hevily  Views(348)  Comments(0Edit  收藏  举报