我在ajax之后重新加载div,如下所示:
$('.comment_form').on('submit', function(e){
e.preventDefault();
.....
success: function(data) {
$('.result').html(data);
$(".comments-body").load(" .comments-body > *"); // reload div comments-body from comments
},
在div .comments-body
中有一个表格。
表格:
<form class="comment_form" action="" method="POST" role="form">
.....
<button type="submit" class="btn btn-primary" name="submit_nested_comment">Submit</button>
</form>
在动态重新加载div之后,无法再次提交此表格。只有经过硬刷新。我该如何解决这个问题?
您可以按其ID而不是像这样的类加载div:
$("#divid").load(" #divid");