Jquery Phonegap中的AJAX不起作用

Jquery Phonegap中的AJAX不起作用,jquery,ajax,cordova,phonegap-cli,Jquery,Ajax,Cordova,Phonegap Cli,这是我在index.js中的代码: $.ajax({ type: 'GET', data: {registrationdata: registrationDataJson}, async: false, url: 'https://example.com/push_reg', success: function(data){ alert("Your device has been successfully registered for pu

这是我在index.js中的代码:

$.ajax({
    type: 'GET',
    data: {registrationdata: registrationDataJson},
    async: false,
    url: 'https://example.com/push_reg',
    success: function(data){
        alert("Your device has been successfully registered for push notifications with device id of: " + data);
    },
    error: function(){
        alert('There was an error registering your device');
    }
});

我已经尝试了异步打开和异步关闭。我没有从成功或错误中得到任何警告。我首先在
/push\u reg
路由的位置放置一条日志行。如果我在桌面浏览器中点击它,它会记录,但不会从应用程序中点击。我有
警报(registrationDataJson)就在这个代码块之前(
registrationDataJson
是一个字符串化的JSON),所以我知道数据是好的。我有
alert('after')直接位于我从未点击过的代码块之后,因此我知道它永远不会通过此代码块。

您可能需要详细说明并指出您看到的错误消息代码/错误。检查您的配置以进行设置等。

请检查您的config.xml文件,并确保您具有以下内容:

<plugin name="cordova-plugin-whitelist" source="npm" spec="1.1.0" />
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" />

<preference name="permissions" value="none"/>


应该是
成功
完成
您应该详细说明“未工作”。失败功能是否启动?控制台中是否有错误?“网络”选项卡中是否有错误代码?代码被之前的代码卡住了吗?另外,不要将async设置为false。javascript不是一个好的做法。@MaxBaldwin-编辑的问题。你的控制台说什么?@OliverQueen-因为我正在处理推送通知并保存设备注册数据,所以实际上我正在设备上测试。