I have a web application built with jQuery Mobile and PHP (CodeIgniter framework). Now I\'m trying to make a PhoneGap version of it as well, to make it distributable as a standa
The reason your form is still submitting and it's trying to change pages is because you have a syntax error in your submit handler Javascript. On line two, event
is not defined so trying to call event.preventDefault()
errors. Although the handler fails, the browser still submits the form using it's default action
and method
.
Either change your function signature to function(event) {
or simply return false from the function. Returning false
is equivalent to preventing default.
$('#login_form').bind('submit', function () {
//send a post request to your web-service
$.post('http://localhost/app_xcode/account/login', $(this).serialize(), function (response) {
//check if the authorization was successful or not
if (response == true) {
$.mobile.changePage('#toc', "slide");
} else {
alert('login failed');
$.mobile.changePage('#toc', "slide");
}
}, 'JSON');
return false;
});