Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function validateLoginForm() {
- var url = "<%=(request.getContextPath())%>/Login.do";
- var username = document.getElementById("username").value;
- var password = document.getElementById("password").value;
- var params = { "username":username,
- "password":password
- };
- var http = new XMLHttpRequest();
- http.open("POST", url, false);
- http.setRequestHeader("X-Requested-With","XMLHttpRequest");
- http.setRequestHeader("Content-type", "application/json");
- http.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- $("html").html(this.responseText);
- }
- };
- http.send(JSON.stringify(params));
- return true;
- }
- <form name="loginForm" method="POST" autocomplete="off" onsubmit="return validateLoginForm()">
- ....
- ....
- ....
- <tr id="userNameRow">
- <th id="usernameLabel">Username</th>
- <td align="left"><input name="username" id="username" autocomplete="off" type="text" aria-describedby="loginError"></td>
- </tr>
- <tr id="userPwdRow">
- <th id="passwordLabel">Password</th>
- <td align="left"><input name="password" id="password" autocomplete="off" type="password"></td>
- </tr>
- JSONObject jsonObj = new JSONObject(requestBody);
- String username = (String) jsonObj.get("username");
- String password = (String) jsonObj.get("password");
Add Comment
Please, Sign In to add comment