AJAX XMLHttpRequest POST X-Domain

喜夏-厌秋 提交于 2019-12-08 13:58:16

问题


I am sending an AJAX request using POST over X-Domain for a widget we are producing for our website. The problem we are facing is that this is getting blocked.

My question is - for "modern browsers" [Chrome, Safari, FF, IE8] - it is my understanding that setting "Access-Control" headers

Access-Control-Allow-Origin: http://www.test.com
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: *
Access-Control-Max-Age: 1728000

Will allow these "POST" requests to work ? But for IE7 we need to implement some "custom" JSONP solution?

Am I correct in this ? Anyone ?


回答1:


This works but not using the standard XmlHttpRequest object. For example in IE8 you should use the XDomainRequest object to send the request. For these scenarios, JSONP is actually easier to use and works cross-browser as implemented in jQuery.



来源:https://stackoverflow.com/questions/2794558/ajax-xmlhttprequest-post-x-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!