<html>
<body>
<form id="form">
<input type="test" name="ahh" />
<button class="btn btn-success" value="1">submit</button>
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqBootstrapValidation/1.3.7/jqBootstrapValidation.min.js"></script>
<script>
$(function () {
$("button").click(function() {
$("input", "#form").jqBootstrapValidation({
submitSuccess: function(booking, e) {
e.preventDefault();
alert("This is an alert 1, 2, 3, 4, ...... (n) after submit");
}
});
});
});
</script>
</body>
</html>
我认为SubmitSuccess会多次触发。我该如何解决这个问题?
注意:因为我使用AJAX提交表单,所以其中存在preventDefault