【发布时间】:2019-07-09 03:56:58
【问题描述】:
我正在使用 jquery 和 php 通过 ajax 调用获取动态数据 成表格格式。我有一个可供选择的选项 不同的公司。Onselect 我会得到一些特定的数据 使用 ajax 的员工我将该数据绑定到表。但问题是如果 我选择公司 1 然后我可以绑定公司 1 的数据。onchange 公司 1 的公司 2 数据应该消失,公司 2 的数据 只有在那里。但在我的情况下 onchange company 2 以前的数据是 还在。
下面是我的ajax调用代码:
$.ajax({
method: "GET",
dataType: 'json',
url:"getdata.php?id="+emp_id,
success:function (response){
$.each(response, function( index, value ) {
$("table.table").append("<tr><td>" + response.emp_name + "</td><td>" + "</td><td><input type='file'></td></tr>");
});
},
});
下面是我的html:
<table class="table">
<thead>
<tr>
<th>Employee Name</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
【问题讨论】: