且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery AJAX 表单提交两次

更新时间:2022-12-11 13:48:36

很可能您正在使用 buttonsubmit 来触发 ajax 事件.试试这个:

It's most likely that you're using a button or submit to trigger the ajax event. Try this:

$('#exportForm').submit(function(e){
        e.preventDefault();
        $.ajax({
            type: "POST",
            url: $(this).attr( 'action' ),
            data: $(this).serialize(),
            success: function( response ) {
                console.log( response );
            }
        });

        return false;
    });