AJAX XMLHttpRequest POST X-Domain [英] AJAX XMLHttpRequest POST X-Domain

查看:208
本文介绍了AJAX XMLHttpRequest POST X-Domain的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用POST over X-Domain发送一个AJAX请求,用于我们为我们的网站生成的小部件。

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.

我的问题是 - 对于现代浏览器[Chrome,Safari,FF,IE8] - 这是我的理解设置访问控制标题

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

将允许这些POST请求工作?但对于IE7,我们需要实现一些定制的JSONP解决方案?

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

推荐答案

这可以工作,但不使用标准的XmlHttpRequest对象。例如,在IE8中,您应该使用 XDomainRequest 对象发送请求。对于这些情况,JSONP实际上更容易使用,并且工作在跨浏览器在jQuery中实现

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.

这篇关于AJAX XMLHttpRequest POST X-Domain的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆