Guest User

Untitled

a guest
Aug 22nd, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. JQuery AJAX response handling
  2. $('#drop').click(function(e) {
  3. e.preventDefault();
  4. $('#login').slideToggle(1000);
  5. });
  6.  
  7. $('#sub').click(function(e) {
  8. e.preventDefault();
  9. $('#info').html('<img src="img/load.gif" />')
  10. $.post('login.php', {user: document.getElementById('user').value, pass: document.getElementById('pass').value}, function(response) {
  11. if (response == 'ok')
  12. {
  13. $('#login').slideUp(500);
  14. $('#info').html('');
  15. $('#joocy').html('<img src="img/load.gif" />').load('manage.php');
  16. }
  17. else if (response == 'error')
  18. {
  19. $('#info').html('Invalid user/pass');
  20. }
  21. });
  22. });
  23.  
  24. if ($row = mysql_fetch_array($result))
  25. {
  26. echo 'ok';
  27. }
  28. else
  29. {
  30. echo 'error';
  31. }
  32.  
  33. $.post('login.php', {user: document.getElementById('user').value, pass: document.getElementById('pass').value}, function(response) {
  34. if (response == 'ok')
  35. {
  36. $('#login').slideUp(500);
  37. $('#info').html('');
  38. $('#joocy').html('<img src="img/load.gif" />').load('manage.php');
  39. }
  40. else if (response == 'error')
  41. {
  42. $('#info').html('Invalid user/pass');
  43. }
  44. var tmpText = "" + response.length + ": ";
  45. for(var tmpI=0; tmpI<response.length; tmpI++) {
  46. tmpText += response.charCodeAt(tmpI) + " ";
  47. }
  48. $("<fieldset></fieldset>").text(tmpText).appendTo("#info");
  49. });
  50.  
  51. if($.trim(response)==='error')
  52. {
  53. //
  54. }
Add Comment
Please, Sign In to add comment