我正在使用jquery驗證插件來驗證ajax submited窗體。如果有一些錯誤的服務器端,ajax調用返回表單的html。jquery驗證插件裏面的ajax加載內容
問題是,如果這發生在ajax doens't工作了。我需要像jquery validation插件一樣的「live」jquery函數。
這裏是我的代碼:
$('#myform').validate({
submitHandler: function(form) {
formData = $(form).serialize();
$.ajax({
type: "POST",
url: form.action,
data: formData ,
dataType: 'json',
success: function(response){
if(response.status == "success")
window.location.reload(true);
else
$('#myformdiv').html(response.html);
},
error: function(response){
}
});
return false;
}
});
指向僅包含斷開鏈接的其他答案的鏈接。不是很有用。 – 2017-09-01 13:23:28