0

I have a problem, after first submit form success and load div,Form no submit update data second time.

Here code, please help me, thanks.

$(document).ready(function() {
  $('.edit_gv').click(function() {
    var id = 'modal_' + $(this).val();
    $('#' + id).modal({
      backdrop: 'static',
      keyboard: false
    });
  });

  $('.editgv_form').submit(function(e) {
    /*$('.editgv_form').on('submit', 'input[name=submit]', function (e) {*/

    e.preventDefault(); // Prevent Default Submission

    $.ajax({
      url: $path + 'edit_gv.php',
      type: 'POST',
      data: $(this).serialize() // it will serialize the form data

    })

    .done(function(data) {
        $('#modal_edit_gv').modal('hide');
        $('body').removeClass('modal-open');
        $('.modal-backdrop').remove();

        $("#all_giang_vien").load($path + '/giang_vien_load.php');
      })
      .fail(function() {
        alert('Ajax Submit Failed ...');
      });
    return false;
  });

});
Barmar
  • 741,623
  • 53
  • 500
  • 612
Orange
  • 15
  • 4
  • Does the `.done()` function replace the HTML containing the form? Then see http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements – Barmar Nov 07 '16 at 09:13
  • I don't understand. please explain for me. thanks – Orange Nov 07 '16 at 09:42
  • Is the form inside the `#all_giang_vien` div that you overwrite in the `.done()` function? – Barmar Nov 07 '16 at 15:32
  • yes sir, I think error #all_giang_vien div that you overwrite in the .done(). but I can not fix it – Orange Nov 07 '16 at 16:26
  • Read the linked question, it explains how to create event bindings that persist when the element is overwritten. – Barmar Nov 07 '16 at 16:33

0 Answers0