[英]PhoneGap-Plugin-Push or jQuery/Ajax
I'm trying to make ajax call to a php-file which saves registration-id of client. 我正在尝试对保存客户端注册ID的php文件进行ajax调用。 For this i use this javascript code: 为此,我使用以下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) {
});
}
}; };
Where MySenderId & MyUrl is a placeholder. 其中MySenderId和MyUrl是占位符。 The Registration ID is showen in #gcm_id but the ajax-call not working. 注册ID显示在#gcm_id中,但ajax调用不起作用。 How to debug this? 如何调试呢? How to solve the problem? 如何解决问题?
解决-Ajax调用工作正常-php文件中有错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.