Please, I need some help. I'm trying to develop an application with phonegap x jquery / strong> Ajax and I have the following situation:
I'm on a page, after the user enters an email and password, I call ajax , from an external page to validate, in js . As below:
Item 1:
$('form').submit(function() {
console.log( "submit!" );
var postData = $(this).serialize();
$.ajax({
type: 'POST',
data: postData,
url: 'http://localhost/service/service_usu.php',
success: function(data){
//alert('ret:'+data);
if (data!='11') {
//alert('usuario nao validado!');
window.location='http://localhost/usu_incons.html';
}
if (data=='11') {
alert('usuario validado!');
//window.location='http://localhost/inc_usu_ok.html';
}
},
error: function(){
//console.log(data);
alert('There was an error adding your comment');
}
});
return false;
});
Perfect, checks the user and when negative calls the page usu_incons.html
, and on this page shows the reason for the inconsistency and has a back button: <a id="voltar" href="index.html" data-role="button">Usuário ou email inexistente!</a>
Perfect, it returns to the index.html
page. On this page index.html
the javascript button of item 1 above does not work anymore, I already tried item 3 below and nothing .... ... I do not know what to do so you can re-enter the email and password and call the js / ajax > again.
item 3:
$(document).ready(function(){
app.initalize;
app.receivedEvent;
console.log( "ready!" );
});
var app = {
initialize: function() {
this.bindEvents();
//console.log( "entrou initialize" );
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
$(document).on("pagecontainershow", app.onDeviceReady);
},
onDeviceReady: function() {
app.receivedEvent('deviceready')
},
receivedEvent: function(id){
alert($.mobile.pageContainer.pagecontainer('getActivePage').data('http://localhost/usu_incons.html'));
}
}