Advertisement
Guest User

Untitled

a guest
May 30th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. if($.trim(email).length>0 && $.trim(password).length>0) {
  2.  
  3.  
  4.  
  5. $.ajax({
  6. type: "POST",
  7. url: "http://www.example.com/app/login.php",
  8. crossDomain: true,
  9. dataType: 'json',
  10. data: $.trim(frm.serialize()),
  11. beforeSend: function(){
  12. $('#loader').css({ display: "block" });
  13. },
  14. success: function(data,status,XHR) {
  15. handleData(data);//handle the servers respond
  16. },
  17. error: function(httpReq,status,exception){
  18. alert("Network error: "+status+" "+exception);
  19. $('#loader').css({ display: "none" });
  20. }
  21.  
  22. });
  23. }
  24.  
  25. function handleData( responseData ) {
  26. var access = responseData;
  27.  
  28. if(access == "good"){//server respond good username/pass
  29. alert("Welcome");
  30. $('#loader').css({ display: "none" });
  31. }
  32. }
  33. else{
  34. alert("Your username and password didn't match.");
  35.  
  36. $('#input_password').val('');
  37. $('#loader').css({ display: "none" });
  38.  
  39. }
  40. console.log(responseData);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement