兼容IE和Firefox的XMLHttpRequest代码

var xmlhttp=null;
function createXMLHTTPReaquest(){
 if(window.XMLHttpRequest){
  xmlhttp=new XMLHttpRequest()
 }else if(window.ActiveXObject){
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
 }
}

 调用示例:

function callArticleTitle(v){
 createXMLHTTPReaquest();
 sql="?ac=callArticleTitle&dzfl="+v;
 xmlhttp.open("POST",sql,false);
 xmlhttp.send(null);
 res=xmlhttp.responseText;
 resArr=res.split("|||"); 
 getid("articleTitle").options.length=0;
 for (v in resArr){
  arr=resArr[v].split("@@");
    getid("articleTitle").options.add(new Option(arr[1],arr[0]));
 }
}

 

function getid(id){return document.getElementById(id)}

你可能感兴趣的:(sql,IE,Microsoft,firefox)