I have an issue. I have a login page, which is the first page in my mobile application and contains two fields: username and password, and a submit button. Upon submit, I do an ajax call to check the validity, if successful, it switches pages to the home page.
The problem: if successful, it shows the login page, with both fields blank for 1-2 seconds then finally switches to the home page. Extremely slow or laggy.
$(document).bind('pageshow', function () {
$('#loginSubmit').on("click", function(){
$('#loginSubmit').button('disable');
var formData = $("#loginForm").serialize();
console.log(formData);
$.ajax({
type: "POST",
url: "php/checkLogin.php",
cache: false,
data: formData,
success: function(data){
var check = $.parseJSON(data);
console.log(check);
if (check.approved == 1)
{
$.mobile.changePage('#home');
username = $("#username").val();
}
else
{
// wrong username or password
}
}
});
});
});
I've added a global loading spinner (not shown here), but that only shows up for half a second and disappears. I'm not sure how to handle this.
Console log:
POST http://localhost/jquery/php/checkLogin.php 200 OK 1.02s
POST http://localhost/jquery/ 200 OK 48ms
The first call seems to be the valid check, the second one I'm assuming is loading the home page.