我正在尝试执行ajax调用,如下所示:
(function () {
"use strict";
document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );
function onDeviceReady() {
// Handle the Cordova pause and resume events
document.addEventListener( 'pause', onPause.bind( this ), false );
document.addEventListener( 'resume', onResume.bind( this ), false );
$.ajax({
url: 'https://www.path.com/Controller/Action',
async: false,
type: "GET",
dataType: "json",
beforeSend: function () { $.mobile.loading('show'); },
success: function (DataToFillSelect) {
$.each(DataToFillSelect, function (val, item) {
$('#Select').append(
$('<option></option>').val(item.Value).html(item.Text)
);
});
},
error: function () {
},
complete: function () { $.mobile.loading('hide'); },
})
// TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
};
function onPause() {
// TODO: This application has been suspended. Save application state here.
};
function onResume() {
// TODO: This application has been reactivated. Restore application state here.
};
} )();
元标记:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src: 'self' 'unsafe-inline' 'unsafe-eval'">
Visual Studio给我的错误如下:
Unrecognized Content-Security-Policy directive 'script-src:'.
index.html (4,0)
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
jquery-1.11.3.js (9626,29)
Failed to load resource
jquery-1.11.3.js (9665,29)
它在20分钟前对我有用但在此之前我有一个不同的问题,我解决了Old Qestion,现在我坐在这里遇到了这个问题。
通过AdobePhoneGap构建器构建它,通过visual studio构建它
在模拟器上尝试(这可以用于某种原因)
问题似乎只发生在Android设备上而不是模拟器上我的Android手机有问题吗?
答案 0 :(得分:0)
像我所要做的那样接缝就是将元标记更改为
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-eval' 'unsafe-inline';">
那么再次对手机应用程序有多安全? 在网页上我可以看到问题,但在ios / windows8 / android应用程序上,某人可能会做同样恶作剧的事情
为了安全起见,我认为将来不得不重新修改元标记:) 如果你有任何好的阅读,我想你可以与我分享一些,所以它可能会帮助将来的人!
让我们希望我不会再说这件事,因为它有效。