How do I close a modal window after AJAX success

前端 未结 6 1039
梦如初夏
梦如初夏 2020-12-17 14:19

I have a button which opens a modal but I have prevented the modal close by clicking background or ESC key.

My button looks like this:

6条回答
  •  感动是毒
    2020-12-17 15:09

    You can try something like below. Untested but you'll get the idea.

    $.ajax({
      url: 'yourscript.php',
      data: $('form#yourForm').serialize(),
      type: 'post'
    }).done(function(response) { 
      // trigger modal closing here since ajax is complete.
    });
    

提交回复
热议问题