Layui 更新Table 表格内容的值
$.ajax({ //请求方式 type: "POST", //请求地址 url: "/", //数据,json字符串 data: { }, //请求成功 success: function (result) { if (result.status) { //比如说你请求接口后需要手动的更新表格中的值,而不是改变table 的model 值,可以通过一下方法做到 for (var i = 0; i < result.resultData.length; i++) { // 遍历 tr $('.layui-card-body .layui-table-box .layui-table-body .layui-table tbody tr').each(function (j) { if ($(this).children('td[data-field="TrackingNumber"]').text() == result.resultData[i].TrackingNumber && $(this).children('td[data-field="CarriersName"]').text() == result.resultData[i].CarriersName) { $(this).children('td[data-field="GetTrackStatus"]').html('<div class="layui-table-cell laytable-cell-1-0-1">' + result.resultData[i].GetTrackStatus+'</div>') return false; } }); } } else { layer.alert(result.msg) } layer.close(index); }, //请求失败,包含具体的错误信息 error: function (e) { layer.alert(e.status + "," + e.responseText); } });