I'm trying to make ajax call to a php-file which saves registration-id of client. For this i use this javascript code:
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. The Registration ID is showen in #gcm_id but the ajax-call not working. How to debug this? How to solve the problem?
解决-Ajax调用工作正常-php文件中有错误。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.