簡體   English   中英

PhoneGap-Plugin-Push或jQuery / Ajax

[英]PhoneGap-Plugin-Push or jQuery/Ajax

我正在嘗試對保存客戶端注冊ID的php文件進行ajax調用。 為此,我使用以下javascript代碼:

var app = {
// Application Constructor
initialize: function() {
    this.bindEvents();
},

// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);
},

// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
    var push = PushNotification.init({
        android: { senderID: "103232657886" },
        ios: { alert: "true", badge: "true", sound: "true" },
        windows: {}
    });

    push.on('registration', function(data) {
        $("#gcm_id").text(data.registrationId);

        $.ajax({
            url: "http://sebtm.lima-city.de/AT-GCM/insertRegistrationId.php",
            type: "POST",
            dataType: 'text',
            data: {registrationId: data.registrationId},
            success: function (data) {
                alert(data);
            }
        });
    });

    push.on('notification', function(data) {
    });

    push.on('error', function(e) {
    });
}

};

其中MySenderId和MyUrl是占位符。 注冊ID顯示在#gcm_id中,但ajax調用不起作用。 如何調試呢? 如何解決問題?

解決-Ajax調用工作正常-php文件中有錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM