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();
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");
}
});
});