.on('success.form.fv', function(e) {
// Prevent form submission
e.preventDefault();
var $form = $(e.target),
fv = $form.data('formValidation');
// Use Ajax to submit form data
$.ajax({
url: $form.attr('action'),
type: 'POST',
data: $form.serialize(),
cache: false,
success: function (data, textStatus, jqXHR) {
alert("Your changes have been saved")
}
});
});
我在success.form.fv
的{{1}}上使用了ajax调用。
在我提交表单之前,如何添加是和否选项的确认对话框?
答案 0 :(得分:0)
将代码更改为:
.on('success.form.fv', function(e) {
// Prevent form submission
e.preventDefault();
if(confirm('Submit the form ?')){ //user chooses Ok
/**** Your AJAX code here ****/
} else {
// user chooses cancel. Do not submit the form
}
});