Skip to content

Instantly share code, notes, and snippets.

@cfjedimaster
Created February 16, 2013 18:24
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cfjedimaster/4968046 to your computer and use it in GitHub Desktop.
$(document).on("pageinit", "#mainPage" ,function(event) {
checkConnection();
console.log("pageinit");
$("#submitButton").on("touchend",function(e) {
console.log("touchend for button");
e.preventDefault();
var btn = $(this);
//disable the button so we can't resubmit while we wait
btn.attr("disabled","disabled");
var u = $("#username").val();
var p = $("#password").val();
if(u === '' || p === '') return;
$.get(serviceURL + "?method=login", {login:u, password:p, returntype:'json'}, function(res) {
//require res.user and it being an array
if(!res.user || !res.user[0]) return;
btn.removeAttr("disabled");
if(res.user[0].status == "InvalidData") {
navigator.notification.alert("Your login failed.", function() {});
} else {
user = res.user[0];
$.mobile.changePage("scan.html");
}
},"json");
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment