繁体   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