xdr = new XDomainRequest(); // Creates a new XDR object.
xdr.timeout = 3000;//Set the timeout time to 3 second.
xdr.onload = function(){
try {
var res = $.parseJSON(xdr.responseText);
callback(res)
} catch(e) {
console.log("Json format");
//throw 'Invalid JSON: ' + xdr.responseText;
}
};
xdr.onerror = function(){
console.log("can't get data from server")
$('#ServerMessage').show();
};
xdr.ontimeout = function () {
$('#ServerMessage').show();
};
xdr.open(method,this.url); // Creates a cross-domain connection with our target server using GET method.
xdr.send(JSON.stringify(object)); //Send string data to server
我已经能够发出一个简单的POST请求,但无法向其添加POST数据。