如何在IE 8+ CORS中发送POST数据到Laravel(使用XDomainRequest)

时间:2017-12-28 04:07:34

标签: javascript ajax internet-explorer

 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数据。

0 个答案:

没有答案