【问题标题】:Ajax POST works in Desktop but not in Phonegap App or AndroidAjax POST 适用于桌面,但不适用于 Phonegap 应用程序或 Android
【发布时间】:2016-02-10 08:20:44
【问题描述】:

我有这个 GLOBAL 函数,它在 Android 的 Phonegap 桌面应用程序或 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:');
        }
    });
};              

【问题讨论】:

  • 你能发布完整的 HTML 页面吗...

标签: javascript android ajax cordova


【解决方案1】:

尝试使用完整的 url 而不是

url: "push_set.php"

喜欢

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    相关资源
    最近更新 更多