Guest User

Untitled

a guest
Jan 20th, 2019
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. /* Verify login credentials
  2. *
  3. * @param username, password
  4. * @param activityElement - element in which to place activity indicator
  5. * @param location - location to refresh after success
  6. * @return none
  7. */
  8. function verify_login(username, password, activityElement, location)
  9. {
  10. $.ajax({
  11. type: 'POST',
  12. url: '<?=site_url('ajax/eval_login')?>',
  13. data: { username: username, password: password },
  14. beforeSend:function() {
  15. window.savedHtml = $(activityElement).html();
  16. $(activityElement).html('<div id="activity"></div><div class="text-center">Verifying </div>');
  17. $('#activity').activity(); //neteye activity indicator plugin
  18. },
  19. success:function(data) {
  20. data = $.parseJSON(data);
  21. if (data.success) {
  22. $(activityElement).html(window.savedHtml);
  23.  
  24. //fades in success message then performs function
  25. set_message('Success!',function() {
  26. alert(location);
  27. window.location.href = "<?=site_url()?>/" + location;
  28. });
  29. } else {
  30. $(activityElement).html(window.savedHtml);
  31. set_message(data.error);
  32. }
  33. $('#activity').activity(false);
  34. set_clicks();
  35. },
  36. error:function(){
  37. set_message('<strong>Oops!</strong> Try that again in a few moments.</p>');
  38. $('#activity').activity(false);
  39. $(activityElement).html(window.savedHtml);
  40. }
  41. });
  42. }
  43.  
  44. data = $.parseJSON(data);
Add Comment
Please, Sign In to add comment