【问题标题】:ajax request not working when build app using build.phonegap.com使用 build.phonegap.com 构建应用程序时,ajax 请求不起作用
【发布时间】:2018-03-26 14:56:16
【问题描述】:

我尝试了一周的各种解决方案,但没有任何效果,我不知道如何调试我的发布应用程序,在调试模式下,应用程序一切正常!这是我的html代码

<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-eval' data: blob: filesystem: ws: gap://ready file: cdvfile: https://ssl.gstatic.com *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; img-src * data: 'unsafe-inline'; connect-src * 'unsafe-inline'; frame-src *; worker-src *; child-src *;">

$.post("https://xxxxx/api/").done(function (data) {                             
   console.log(data);
})

config.xml:

<access origin="*" />
<allow-navigation href="*" />
<allow-intent href="*" />

php 代码:

header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
$sendData[status] = 'ERROR';
$sendData[message] = 'no action command';
echo json_encode($sendData);    
exit();

我在这里错过了什么?

【问题讨论】:

  • 它工作正常...我认为问题是缓存问题

标签: php android ajax phonegap-build html-framework-7


【解决方案1】:

您是否尝试在 config.xml 文件中包含应用中的白名单插件

cordova plugin add cordova-plugin-whitelist
cordova prepare

你可以在这里阅读:https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/

【讨论】:

    【解决方案2】:

    由于冲突问题,在使用 Framework7 时,无法使用 $ 访问 DOM7。而不是 '$' 使用 '$$'。 DOM7 在应用程序初始化时分配给 $$。你可以检查一下。查看以下链接了解更多信息http://framework7.io/docs/dom7.html

    【讨论】:

    • 我说它在调试模式下工作正常...我会尝试使用 DOM7
    猜你喜欢
    • 1970-01-01
    • 2020-05-31
    • 1970-01-01
    • 2014-12-25
    • 2021-11-29
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 1970-01-01
    相关资源
    最近更新 更多