顽皮哥教你做达人脚本

来源:互联网 发布:信托网络个人理财产品 编辑:程序博客网 时间:2024/05/01 01:23
function test(data){
    alert(eval(data).name);    
}
function XHR(){
this._xhr = null;
}
XHR.prototype.getInstance = function(){
if(window.ActiveXObject)
this._xhr = new ActiveXObject("Microsoft.XMLHttp");
if(window.XMLHttpRequest)
this._xhr = new XMLHttpRequest();
return this;
}
XHR.prototype.ajaxProc = function(url,callback,value){
this._xhr.open("POST",url,true);
this._xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
this._xhr.onreadystatechange = function(){
if(this.readyState==4 & this.status == 200){
eval(this.responseText);
}
}
this._xhr.send("callback=" + callback + "&value=" + value);
this._xhr = null;
}
var obj = new XHR();

obj.getInstance().ajaxProc("2.php","test","{\'name\':\'swat\',\'age\':32}");

//天津顽皮哥

$(function(){
    $.ajax({
        type:"POST",
        async:true,
        url:"2.php",
        data:{"name":"swat","age":32},
        success: function(data){
            alert(data);
        },
        error: function(){
            alert("fail");    
        }
    });    
});

0 0
原创粉丝点击