火狐OS的应用程序,在Firefox OS的应用程序CORS [英] firefox OS app,CORS in Firefox os app

查看:199
本文介绍了火狐OS的应用程序,在Firefox OS的应用程序CORS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发web应用程序(没有托管的应用程序)在Firefox OS。 我想用XMLHTTP请求访问网站的XML / JSON数据。但它给错误的CORS不允许访问数据。我知道添加访问控制 - 允许 - 原产地的网站标题和启用CORS可能会导致安全问题。 但是,他们任何替代方法通过XMLHTTP请求访问数据源?

I have been developing web-app(not hosted app) in firefox OS . I want to access the websites xml/JSON data using XMLHttp request. but it gives error as CORS not allowed to access the data . I know about to add 'Access-Control-Allow-Origin' header in website and enabling CORS may cause security issues. But is their any alternate way to access the data feed via XMLHttp request?

推荐答案

首先改变你的表现有以下字段(键入人会被人们遗忘了):

First change your manifest to have the following fields (the type one gets forgotten by people):

"type": "privileged", 
"permissions": {
    "systemXHR" : {}
}

二,将所有你的JavaScript code到A的单独的的JS文件。因为它不允许有行内标签在特权的应用程序。

Second, move all your JavaScript code to a separate JS file. Because it's not allowed to have inline tags in a privileged application.

三用mozSystem构造类似raidendev说:

Third use the mozSystem constructor like raidendev said:

var xhr = new XMLHttpRequest({ mozSystem: true });

这篇关于火狐OS的应用程序,在Firefox OS的应用程序CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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