Ajax POST适用于桌面,但不适用于Phonegap App或Android

Ajax POST works in Desktop but not in Phonegap App or Android

本文关键字:适用于 Phonegap App 不适用 Android POST 桌面 Ajax      更新时间:2023-09-26

我有这个全局功能,在 Phonegap 桌面应用程序或 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"