簡體   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