Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. //Cách 1
  2. $('#login-buttn').on('click', function () {
  3. $.ajax({
  4. type: 'POST',
  5. url: '/login',
  6. data: {
  7. username: $('#username').val(),
  8. password: $('#password').val()
  9. },
  10. dataType: 'json',
  11. async: false,
  12. success: function (response) {
  13. if (response.status == 'granted') {
  14. alert('Đăng nhập thành công');
  15. } else {
  16. alert('Đăng nhập thất bại');
  17. }
  18. }
  19. });
  20. });
  21.  
  22. //Cách 2
  23. $('#login-form').submit(function(e) {
  24. $.ajax({
  25. type: 'POST',
  26. url: '/login',
  27. data: {
  28. username: $('#username').val(),
  29. password: $('#password').val()
  30. },
  31. dataType: 'json',
  32. async: false,
  33. success: function (response) {
  34. if (response.status == 'granted') {
  35. alert('Đăng nhập thành công');
  36. } else {
  37. alert('Đăng nhập thất bại');
  38. }
  39. }
  40. });
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement