Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
- <script>
- $(document).ready(function(){
- $('#login').click(function(event){
- event.preventDefault();
- var username = $("#username").val();
- var password = $("#password").val();
- var servlet = '${pageContext.request.contextPath}/LoginServlet';
- $.ajax({
- type: 'GET',
- url: servlet,
- data: {username: username, password: password},
- success: function(data) {
- // check data for error
- if (data.includes("ERROR:")) {
- var errorMessage = data;
- document.getElementById('error').innerHTML = errorMessage;
- return false;
- } else {
- window.location = '${pageContext.request.contextPath}/jsp/menu.jsp';
- }
- },
- error: function(data){
- alert("fail");
- }
- });
- });
- $('#signup').click(function(event){
- event.preventDefault();
- window.location = '${pageContext.request.contextPath}/jsp/new_user.jsp';
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement