繁体   English   中英

Ajax POST在桌面环境中有效,但在Phonegap App或Android中无效

[英]Ajax POST works in Desktop but not in Phonegap App or Android

我有这个GLOBAL函数在Phonegap Desktop应用程序或Android的Chrome Mobile中不起作用,它仅在Chrome PC版本中起作用...我将此函数与onClick事件一起调用, #suich是一个开关复选框SVG

function setPush() {
    var nick_ = window.localStorage.getItem("username");
    var notify = window.localStorage.getItem("option");
    $.ajax({
        type: "POST",
        url: "push_set.php",
        data: ({
            nick: nick_,
            opcion: notify
        }),
        cache: false,
        dataType: "json",
        success: function(data) {
            if (data.status == 'success') {
                if (notify == 1) {
                    myApp.alert('Notifications disabled', 'Notice:');
                    $('#suich').prop('checked', false);
                } else {
                    myApp.alert('Notifications enabled', 'Notice:');
                    $('#suich').prop('checked', true);
                }
            } else if (data.status == 'error')
                alert('Connection problems', 'Warning:');
        }
    });
};              

尝试输入完整网址,而不是

url: "push_set.php"

喜欢

url: "www.yourdomain.com/push_set.php"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM