Form form in JSP:
<form action= "" id= "form" >
<table style= "width:80%;height:80%;" border= "1" cellspacing= "0" cellpadding= "0" align= "center" valign= "Middle" >
<tr>
<textarea rows= "10%" name= "content" id= "content" style= "width:100%;height:30%;" >
</textarea>
<div id= "abc" align= "Center" >
<input class= "button" name= "button" id= "button" type= "button" value= "Commit" onclick= "Save ()"/>
<input class= "button" name= "reset" id= "reset" type= "reset" value= "reset"/>
</div>
</tr>
</table>
</form>
JS in the Save method:
function Save () {
document.getElementById (' button '). disabled=true;
var content= document.getelementbyid (' content '). Value;
if (lefttrim (content) = = "") {
Alert ("Content cannot be empty");
document.getElementById (' button '). Disabled=false;
return false;
}
var data = {};
Data.body = {
Messagesql:content,
};
var Titlej = json.stringify (data);
$.ajax ({
URL: "/base/dboperation/operation",
Type: "POST",
DataType: "JSON",
ContentType: "Application/json",
Data:titlej,
Success:function (res) {
var retjson=json.stringify (res);
var evalue =eval (' (' +retjson+ ') ');
var error=evalue["errors"];
alert (error);
document.getElementById (' button '). Disabled=false;
$ (' #response '). Val (Error);
},
Error:function () {
Alert ("Return failed!");
document.getElementById (' button '). Disabled=false;
}
});
}
button to prevent duplicate submissions (click Submit after the Submit button dimmed, after the operation has been completed recovery)