【问题标题】:how to use the cross domain xml file with my project如何在我的项目中使用跨域 xml 文件
【发布时间】:2014-03-29 06:58:53
【问题描述】:
I have a xml file. how can i use the xml file and access the cross domain request in angularjs $http request.

<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
/* cross-domain contents goes here */
</cross-domain-poliy>

如何在我的项目中使用这个 xml 文件并使跨域访问为 true。

【问题讨论】:

    标签: cross-domain


    【解决方案1】:

    CrossDomain.xml 文件允许 Flash 应用程序对与提供 SWF 的域不同的域进行 HTTP 调用。通常这用于调用远程服务,但也可用于加载资产。 crossdomain.xml 文件不会影响 HTML 或 JavaScript 代码。

    如果您想对不同的域进行 AngularJS 服务调用,则必须使用 JSONP。从 AngularJS 应用程序执行此操作的最简单方法是使用 $http.jsonp() 方法。不过要小心,因为这样做是cross site scripting 的一种形式。我的偏好是生产站点不使用 JSONP。不过,它可以用于开发目的。

    【讨论】:

    • 这仅适用于 GET 请求。更好的解决方案是使用 CORS。
    猜你喜欢
    • 2010-10-30
    • 1970-01-01
    • 1970-01-01
    • 2012-03-08
    • 2012-08-05
    • 1970-01-01
    • 1970-01-01
    • 2010-11-25
    • 1970-01-01
    相关资源
    最近更新 更多