//This is my function which invokes when my form is submitted
$('#addDataBtn').click(function(){
//here im going to add all my form data to a variable
var fd = {};
fd["orgId"]=$('#orgId').val();
fd["orgSystem"]=$('#orgSystem').val();
fd["hostName"]=$('#hostName').val();
fd["systemId"]=$('#systemId').val();
fd["instanceNo"]=$('#instanceNo').val();
fd["client"]=$('#client').val();
fd["username"]=$('#username').val();
fd["password"]=$('#password').val();
fd["language"]=$('#language').val();
fd["createdBy"]= $('#createdby').val();
fd["updatedBy"]= $('#updatedby').val();
//here im making a ajax call and posting my form data
$.ajax({
url : './add-org-sap-info.gis',
type: 'POST',
data:JSON.stringify(fd),
dataType: 'json',
contentType: "application/json; charset=utf-8",
//this is my logic when i submit a valid form this function will be working
success :function(res){
if(res != null && res=="success"){
$.ajax({
url : './org-sap-info.gis',
type: 'POST',
success :function(res){
if(res != null && res.length > 0)
$('#totbody').html(res);
},
error:function(){
alert("There is someting error at server side.");
}
});
}
//here if i have any errors it should return a alert message
else{
alert(res);
return false;
}
},
// and even here if i fail to submit a valid form this should show me a alert message
问题是,当我提交空表格时,它应该给我相同的表格,而不是给我警报信息,有人可以告诉我如何获得相同的表单页面而不是收到警报消息。
当我在提交无效表单时使用基于spring注释的验证时,我应该获取错误消息而不是警告消息,我的所有Java代码都运行良好但我在jsp文件中遇到问题。
有人可以告诉我如何获得我的验证错误信息吗?
error:function(){
alert("There is something error at server side.");
}
});
});