-1
的這是我的控制檯錯誤:
拒絕連接到URL,因爲違反了內容安全策略
這是元的實際代碼:
<meta http-equiv="Content-Security-Policy" content="connect-src 'self' data: gap: https://ssl.gstatic.com ; style-src 'self' 'unsafe-inline'; media-src *">
我正在開發一個科爾多瓦的android應用程序。我正在嘗試從照片中的劃痕網址中檢索數據。這是的index.html
html>
<head>
<body>
<div role="main" class="ui-content">
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
,這是index.js
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
document.addEventListener('loadcities', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
app.receivedEvent('loadcities');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
if (id === 'deviceready') {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);}
else if (id === 'loadcities') {
var url = "http://uiiuh"
$.getJSON(url).done(function(response){
if(!response.length){
console.warn("Empty list of cities");
}
config.cities = response;
$('body').trigger('city-data');
}).fail(function(data, status, error){
console.error("Something went wrong retrieving the cities via API")
});
}
}
};
app.initialize();
我想僅在控制檯中顯示檢索到的數據。
可能的重複http://stackoverflow.com/questions/31211359/refused-to-load-the-script-because-it-violates-the-following-content-security-po 添加更多你的細節'試着去做:你在開發什麼?網站? Android應用程序?使用節點?科爾多瓦? 顯示一些代碼(更多),我們只是不知道你在說什麼。只有一個元標記不足以理解您的問題。 – Aethyn
你實際上沒有說明你的問題是什麼。 – Makyen
你是否正在追加使這個'http'調用到託管頁面的腳本? – Reyraa