IE中的$ .ajax POST调用问题用于跨域($.ajax POST call issue in IE for cross domain)

所有,这可能是经常重复的问题..但我已经在这一天超过一天..到目前为止它令人失望和令人沮丧...... :(

function (url, requestData) { var jqryXHR = $.ajax({ type: 'POST', url: anotherDomainurl, //contentType: 'application/json; charset=UTF-8', data: { requestParams: requestData } });

}

这在FF和Chrome中运行良好但在IE上没有。在IE中,调用本身没有被触发。我该怎么办才能使它工作......并且要求是用POST进行调用。

我的服务器端代码是java和am设置

header('Access-Control-Allow-Origin','* .anotherDomain.com');

问候

All, This could be oft-repeated question..but i have been at this for over a day..and so far its disappointing and frustrating.. :(

function (url, requestData) { var jqryXHR = $.ajax({ type: 'POST', url: anotherDomainurl, //contentType: 'application/json; charset=UTF-8', data: { requestParams: requestData } });

}

This works fine in FF and Chrome but not on IE.In IE the call itself is not getting triggered .What should i do to make it work...And requirement is to make call with POST.

My server side code is java and am setting

header('Access-Control-Allow-Origin', '*.anotherDomain.com');

Regards

最满意答案

使用jsonp。 它提供了一种从不同域中的服务器请求数据的方法。

http://remysharp.com/2007/10/08/what-is-jsonp/

Was able to solve the problem finally...

For IE, we would have to use the

Cross-domain Request (XDR) for Cross Domain call..instead of XMLHttpRequest

Refer : http://msdn.microsoft.com/en-us/library/dd573303%28v=vs.85%29.aspx

There are some restrictions when using XDR which can be viewed @

http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx

if (window.XDomainRequest) { var xdr = new XDomainRequest(); xdr.open("POST", url); xdr.onload = function () {}; xdr.onerror = function() {}; xdr.onprogress = function() {}; xdr.send("requestData="+jsonData); } else{ jQuery.support.cors = true; var jqXHR = $.ajax({ type : 'POST', url : url, crossDomain: true, data : { requestData : jsonData } }); }

Also at server end, the response should have headers added

Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Allow-Headers

IE中的$ .ajax POST调用问题用于跨域($.ajax POST call issue in IE for cross domain)

所有,这可能是经常重复的问题..但我已经在这一天超过一天..到目前为止它令人失望和令人沮丧...... :(

function (url, requestData) { var jqryXHR = $.ajax({ type: 'POST', url: anotherDomainurl, //contentType: 'application/json; charset=UTF-8', data: { requestParams: requestData } });

}

这在FF和Chrome中运行良好但在IE上没有。在IE中,调用本身没有被触发。我该怎么办才能使它工作......并且要求是用POST进行调用。

我的服务器端代码是java和am设置

header('Access-Control-Allow-Origin','* .anotherDomain.com');

问候

All, This could be oft-repeated question..but i have been at this for over a day..and so far its disappointing and frustrating.. :(

function (url, requestData) { var jqryXHR = $.ajax({ type: 'POST', url: anotherDomainurl, //contentType: 'application/json; charset=UTF-8', data: { requestParams: requestData } });

}

This works fine in FF and Chrome but not on IE.In IE the call itself is not getting triggered .What should i do to make it work...And requirement is to make call with POST.

My server side code is java and am setting

header('Access-Control-Allow-Origin', '*.anotherDomain.com');

Regards

最满意答案

使用jsonp。 它提供了一种从不同域中的服务器请求数据的方法。

http://remysharp.com/2007/10/08/what-is-jsonp/

Was able to solve the problem finally...

For IE, we would have to use the

Cross-domain Request (XDR) for Cross Domain call..instead of XMLHttpRequest

Refer : http://msdn.microsoft.com/en-us/library/dd573303%28v=vs.85%29.aspx

There are some restrictions when using XDR which can be viewed @

http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx

if (window.XDomainRequest) { var xdr = new XDomainRequest(); xdr.open("POST", url); xdr.onload = function () {}; xdr.onerror = function() {}; xdr.onprogress = function() {}; xdr.send("requestData="+jsonData); } else{ jQuery.support.cors = true; var jqXHR = $.ajax({ type : 'POST', url : url, crossDomain: true, data : { requestData : jsonData } }); }

Also at server end, the response should have headers added

Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Allow-Headers