When using jquery submission:
(1)
<button id= "Login" > Login </button>
$ (). Ready (function () {
$ ("#login")
. button ()
. Click (function () {
//alert ("username" +$ ("#userName "). Val ());
$.post ("
checklogin.action",
{"username": $ ("#username"). Val (), "Password": $ ("#password"). Val ()},
function (data) {
//alert (DATA.SUC)
if (data.suc) {
window.location.href= "userlist.action";
} else {
$ ("#error_message"). HTML ("* The username or password is incorrect.");
}
,
"JSON"
);
});
(2)
<input type= "image" Src= "Images/btn_login.png" onclick= "Javascript:submitform ()" id= "Btn_log" width= "" height= " /> "
function SubmitForm () {
if ($ ("#userName"). val () = "")
$ ("#error_message"). HTML ("* User Name can not be null.");
Else if ($ ("#userPassword"). val () = "" "
$ (" #error_message "). HTML (" * Password can not be null. ");
else {
$.post (
"Checklogin.action",
{"username": $ ("#username"). Val (), "Password": $ ("#password"). Val ( )},
function (data) {
if (data.suc) {
location.href= "userlist.action";
} else {
$ ("#error_ Message "). HTML (" * The username or password is incorrect. ");
}
,
" json ");
}
The above two methods, in HTML, form forms are not allowed to appear
<form method= "" action= ""////>
///////
</form>
Otherwise there is an error (click no response, JS function inside the JSON way POST method is not performed).
Remove,<form></form>