肥皂的Ajax跨域问题肥皂、问题、Ajax

2023-09-10 14:20:36 作者:咆哮i

我想用ajax访问另一台服务器上的SOAP的Web服务,但我得到一个访问控制允许起源错误。 Web服务返回XML所以JSONP不能使用和web服务也被用于在另一个应用程序,以便修改可能是最后的选项。任何解决办法?

I'm trying to access a SOAP web service on another server using ajax but I'm getting an Access Control Allow Origin error. The web service returns XML so JSONP can't be used and the web service is also being used in another app so modifications is probably the last option. Any solutions?

推荐答案

如果你不能做到JSONP,那么你的选择是:

If you can't do JSONP, then your options are:

Craete一个服务器代理在网页的域,可以从其他域获取期望的结果,并将其从允许的域中继给你。 如果你愿意限制你的浏览器支持一些现代的浏览器,那么你可以调查跨地资源共享(CORS),这是一个更安全的方式做跨域请求。你可以阅读一下。 通过闪存跨域Ajax支持,需要放置您要访问的服务器的主机在适当的跨域策略文件。请参见这里和的此处一些更多的信息。 Craete a server proxy at the domain of the page that can fetch the desired result from the other domain and relay it to you from the allowed domain. If you're willing to limit your browser support to some modern browsers, then you can investigate Cross Origin Resource Sharing (CORS) which is a "safer" way to do cross-domain requests. You can read about it here. Cross-domain ajax support via Flash which requires the placement of an appropriate cross-domain policy file on the host of the server you want to access. See here and here for some more info.