我已經通過其他線程,並使用一個供參考,但仍然無法找到解決方案。
我的問題是:Ajax請求之前的Jquery表單驗證
我呼籲按一下按鈕的功能,現在該功能驗證我嘗試後使用Ajax請求提交處理數據之後的驗證,問題是我的領域越來越驗證,但Ajax請求不調用。
<input type="button" value="Register" id="registerP" onclick="registerPatient()" class="form-control input-sm btn-success ">
function registerPatient(){
$("#patientRegistration").validate({
rules: {
patientName: {
required: true,
textOnly: true
},
},
messages: {
patientName: {
required: "Please enter the full name",
},
},
submitHandler: function(form) {
$.ajax({
type: "POST",
url: "/LoginMavenSpringMVC/appointment/savePatient",
data: "patientName=" + patientName,
success: function(response){},
error: function(e){}
});
}
});
}
但是,如果我不使用驗證和直接調用Ajax我能夠發佈數據。請提出我要去哪裏錯誤。
給予網址或上傳完成,這樣就可以清楚地看到 –
我不力明白你的意思。 –