Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. $(document).ready(function(){
  2. $('#error').toggle();
  3. $('#submit').click(function(event){
  4. event.preventDefault();
  5. var username = $('#username').val();
  6. var password = $('#password').val();
  7. var servlet = '${pageContext.request.contextPath}/Login';
  8. $.ajax({
  9. type: 'GET',
  10. url: servlet,
  11. data: {username: username, password: password},
  12. success: function(data) {
  13. console.log(data);
  14. if (data.includes("Error:")) {
  15. var errorMessage = data;
  16. document.getElementById('error').innerHTML = errorMessage;
  17. $('#error').toggle();
  18. return false;
  19. } else {
  20. window.location = '${pageContext.request.contextPath}/Feed';
  21. }
  22. },
  23. error: function(data){
  24. alert("fail");
  25. }
  26. });
  27. });
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement