我想将一些数据附加到boostrap模式中的表中,该模式从PHP返回并使用jQuery显示。但是它不能正常工作。
当我发出警报时,它会显示从PHP返回的数据,但该数据未附加或显示模式信息。
$(document).on('click', '.btn-info', function() {
var row = $(this).closest("tr"); // Find the row
var text = row.find(".book_id").text();
$.ajax({
async: false,
url: "../../svr/lib/view-book-details.php",
method: "POST",
data: {
text1: text
},
dataType: "text",
success: function(data) {
//alert(data);
$('#view-table').append(data);
$('#viewModal').modal("show");
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="viewModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add New Publisher</h4>
</div>
<div class="modal-body modal-heigt">
<table class="table table-bordered" id="view-table">
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
您可以在html中添加隐藏按钮:
success: function (data) {
$('#view-table').append(data);
$('#modalHiddenCallBtn').click();
}
然后您可以在此按钮上调用click事件:
<select>
<option value="" selected="">Pick a E-commerce</option>
<option value="https://www.amazon.in/">Amazon</option>
<option value="https://www.flipkart.com/">Flipkart</option>
<option value="http://www.snapdeal.com/">Snapdeal</option>
</select>