我需要从一个网站向另一个域中托管的REST Web服务发出AJAX请求。跨站点AJAX请求
尽管在Internet Explorer中这样做还不错,但其他浏览器(如Mozilla和Google Chrome)则施加了更严格的安全限制,禁止跨站点AJAX请求。
问题是我无法控制该域,也无法控制站点所在的Web服务器。这意味着我的REST Web服务必须在其他地方运行,并且我无法实施任何重定向机制。
这里是JavaScript代码,使异步调用:
var serviceUrl = "http://myservicedomain";
var payload = "<myRequest><content>Some content</content></myRequest>";
var request = new XMLHttpRequest();
request.open("POST", serviceUrl, true); // <-- This fails in Mozilla Firefox amongst other browsers
request.setRequestHeader("Content-type", "text/xml");
request.send(payload);
我怎么能在Internet Explorer旁边其他浏览器这项工作?
@PhiLho在这种情况下,我的目标是调用托管在不同域上的REST服务,不包括动态内容。 – 2008-12-02 19:56:26