weixin_33743880 2017-09-12 13:21 采纳率: 0%
浏览 18

多次提交表格

I have a form with multiple submit. How can i found which button is submitted ?

$("#my_form").live("submit", function(event) {

    event.preventDefault();

    var form_action = $(this).attr("action");
    var form_data   = $(this).serialize();
    // Bonton ?

    $.post(
        // ...
    );
    return false;
});
  • 写回答

1条回答 默认 最新

  • weixin_33682790 2017-09-12 13:24
    关注

    you can verify it using the event parameter

    $("#my_form").live("submit", function(event) {
    
    event.preventDefault();
    
    var form_action = $(this).attr("action");
    var form_data   = $(this).serialize();
    // Bonton ?
    
    $.post(
        // ...
    );
    console.log($(event.target)); // this button was clicked
    
    
    return false;
    

    });

    评论

报告相同问题?