$ .getJSON是否可以使用PhoneGap构建?

问题描述 投票:-1回答:1

任何人都可以在其PhoneGap版本中使用它吗? :

$(function(){
    $.getJSON("http://reddit.com/.json", function(data){
        alert("Success!");
    })
})

在浏览器中工作正常,但是当我构建应用程序时,它无法运行。

我已经将它们添加到config.xml中以将所有域列入白名单

<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<allow-navigation href="*" />
<access origin="*" />
<allow-intent href="*" />

也尝试使用此CSP来构建它,并且不使用它

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">

我从这里得到的:https://github.com/apache/cordova-plugin-whitelist

javascript cordova xmlhttprequest getjson content-security-policy
1个回答
2
投票

我看了一下,并在我自己的PhoneGap Build项目中复制了您的Ajax请求。

© www.soinside.com 2019 - 2024. All rights reserved.