【发布时间】:2021-03-15 03:20:17
【问题描述】:
我通过 PHP 获取数组,我想在表格中追加,但我试图从过去 2 天开始,并使用 stackoverflow 上可用的所有函数,但它不起作用...... 请开发人员帮助我并教我如何在下表中附加输出数据-
PHP 代码:-
$result = $stmt->fetchAll();
foreach($result as $data => $value) {
//$QL QUERY HERE
$data = array('name' => $value["name"], 'amount' => $amount, 'invoice' => $Invoice, 'response' => '200');
echo json_encode($data);
}
exit();
我的 PHP 响应是:-
{"name":"AMAZON_FBA","amount":"1","invoice":"25","response":"200"}
{"name":"AMAZON_IN","amount":"12","invoice":"22","response":"200"}
{"name":"FLIPKART","amount":"42","invoice":"08","response":"200"}
{"name":"PAYTM","amount":"36","invoice":"03","response":"200"}
{"name":"Replacement","amount":"0","invoice":"17","response":"200"}
Ajax:-
$.ajax({
.
.
success: function (data) {
var my_orders = $("table#salesReturnTB > tbody.segment_sales_return");
$.each(data, function(i, order){
my_orders.append("<tr>");
my_orders.append("<td>" + data[i].order.name + "</td>");
my_orders.append("<td>" + data[i].order.invoice + "</td>");
my_orders.append("<td>" + data[i].order.amount + "</td>");
my_orders.append("<td>" + data[i].order.response + "</td>");
my_orders.append("</tr>");
});
});
});
【问题讨论】:
-
可以展示后端部分吗?
-
我已经用后端部分更新了问题
-
你的问题解决了吗??
-
没有人,请帮忙
标签: php jquery json ajax append