0
.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")
      }
    });
});

我正在使用 ajax调用success.form.fvformvalidationIO

如何在提交表单之前添加带有是和否选项的确认对话框?

4

1 回答 1

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
    }
});
于 2015-04-08T04:27:28.690 回答