我的主要表格上有个div:
<div id="dynamic-content">RESULT</div>将数据发送到php文件以通过ajax插入记录之后:
$.ajax({
url: "test.php",
type: "POST",
data: {"mydata": myjson},
dataType: "JSON",
success: function (data) {
$('#dynamic-content').html(''); // blank
$('#dynamic-content').html(data); // load data
}
});在php文件中插入mysql之后,使用表作为结果:
<div class="table-responsive">
<table class="table table-striped table-bordered">
<tr>
<th>PRODUCT</th>
<td><?php echo $product; ?></td>
</tr>
<tr>
<th>PRICE</th>
<td><?php echo $price; ?></td>
</tr>
</table>
</div>在“动态内容”div中没有出现任何内容。为什么?
发布于 2018-12-09 11:01:48
当您回显dataType: "html"时,您必须拥有test.php,因为您将它写成" JSON“,AJAX将搜索test.php文件中不存在的JSON输出,因此编写dataType: "html"将解决您的问题。
https://stackoverflow.com/questions/53691158
复制相似问题