Cordova将不允许对另一个URL的get请求。

互联网指向这个插件https://github.com/agamemnus/cordova-plugin-whitelist。
但是,它对如何安装它没有任何信息吗?这是我的第一个离子科尔多瓦应用。
问题如何允许跨端脚本,以便我可以使用这个插件从cordova应用程序中点击填充文本?
联署材料:
var results = document.getElementById('results');
var r = new XMLHttpRequest();
r.open("GET", "http://www.filltext.com?rows=10&f={firstName}", true);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;
var data = JSON.parse(r.responseText);
console.log(data);
for (var i=0;i<data.length;i++){
results.innerHTML += '<li>'+data[i].f+'</li>';
}
};
r.send();更新


Uncaught :拒绝将字符串计算为JavaScript,因为在以下内容安全策略指令中,‘不安全-eval’是不允许的脚本来源:"default-src 'self'“。Config.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.megster.nfc.reader.ionic" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>NFC Reader</name>
<description>
PhoneGap NFC Reader rewritten with Ionic Framework
</description>
<author email="don.coleman@gmail.com" href="https://github.com/don">
Don Coleman
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="BackupWebStorage" value="none"/>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
</widget>index.html
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="cordova.js"></script>
<script src="js/filters.js"></script>
<script src="lib/ngCordova-nfc/nfc.js"></script>
<script src="js/app.js"></script>发布于 2015-06-11 01:13:12
要安装cordova插件,以下是标准的synthex
cordova plugin add cordova-plugin-whitelist或者你可以直接指向git:
cordova plugin add https://github.com/agamemnus/cordova-plugin-whitelist那么如果您的config.xml已经
如果您的config.xml有访问源线:<access origin="*"/>
最简单的方法(但最不安全)是将这一行添加到index.html头中。
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">查看有关插件页面https://github.com/agamemnus/cordova-plugin-whitelist的更多信息
https://stackoverflow.com/questions/30769924
复制相似问题