• 转载一个完美兼容IE、FF、Opera的Ajax类支持get、post、自定义回调函数


    function Ajax(){ 
        this.httpXML=false; 
        this.init(); 
    } 
    Ajax.prototype.init=function(){ 
        if(window.XMLHttpRequest){ 
            this.httpXML=new XMLHttpRequest();  
            if (this.httpXML.overrideMimeType){ 
                this.httpXML.overrideMimeType("text/xml");  
            } 
        }else if(window.ActiveXObject){ 
            try{this.httpXML = new ActiveXObject("Msxml2.XMLHTTP");}catch (e){  
                 try{this.httpXML = new ActiveXObject("Microsoft.XMLHTTP");}catch (e){}  
            } 
        } 
        if(!this.httpXML){ 
            window.alert("can't create XMLHttpRequest object"); 
            return null; 
        } 
    } 
    Ajax.prototype.send=function(_method,_url,_data,_callback){ 
        this.httpXML.onreadystatechange=function(){ 
            if(this.readyState==4&&this.status==200){ 
                _callback.call(this,this.responseText); 
            } 
        } 
           
        if (_method.toLowerCase() == "get"){  
             //if(navigator.userAgent.indexOf("MSIE")<=0){ 
             //     netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); 
             //} 
             this.httpXML.open(_method, _url, true);  
             this.httpXML.send(null);  
        }else if (_method.toLowerCase() == "post"){  
             this.httpXML.open(_method, _url, true);  
             this.httpXML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
             this.httpXML.send(_data);  
        }  
           
    } 
       
    Ajax.prototype.callback=function(){ 
            
    }  
    
  • 相关阅读:
    PS学习之餐饮行业修图
    python的IDE选择
    python简介与安装
    selenium不能启动firefox浏览器,怎么办?
    selenium定位元素(python)
    如何解决Selenium IDE与Firefox的不兼容问题?
    手工测试的关注点之用户管理
    《Google 测试之道》有感(一)
    LR性能测试衡量指标
    LR集合点与事务
  • 原文地址:https://www.cnblogs.com/breakdown/p/2397971.html
Copyright © 2020-2023  润新知