jsp中form表单:
<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="提交" onclick="save()"/>
<input class="button" name="reset" id="reset" type="reset" value="重置"/>
</div>
</tr>
</table>
</form>
js中save方法:
function save() {
document.getElementById('button').disabled=true;
var content= document.getElementById('content').value;
if (lefttrim(content)=="") {
alert("内容不能为空");
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("返回失败!");
document.getElementById('button').disabled=false;
}
});
}