我有通过AJAX发布的表单.如果我不使用任何其他JavaScript库,它就像一个魅力.
现在我正在使用Bootstrap和jQuery,它不会触发.
代码:
$(function() {
$('form').on('submit', function(e) {
$.ajax({
type: 'post',
url: 'ajax-post.php',
data: $(this).serialize(),
alert($(this).serialize());
success: function() {
$(".alert").show(0).delay(2000).hide(0);
}
});
e.preventDefault();
});
});
Run Code Online (Sandbox Code Playgroud)