1 回答

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以將詳細(xì)信息 url 分成一個(gè)變量,以便在 ajax 調(diào)用成功后使用,如下所示:
document.addEventListener("DOMContentLoaded", () => {
let detail_url = '<?php echo site_url('admin/detail/'); ?>';
$.ajax({
url: "<?php echo site_url('Admin/piljur');?>",
dataType: "json",
type: "POST",
cache: false,
success: function(html) {
var data = "";
for (var i = 0; i < html.tpl.length; i++) {
data += "<tr><td>" + (i + 1) + "</td>" +
"<td>" + html.tpl[i]['nip'] + "</td>" +
"<td><a href='" + detail_url + html.tpl[i]['nip'] + "' >detail</a></td></tr>";
}
$("#datatabel").append(data);
}
});
}
- 1 回答
- 0 關(guān)注
- 167 瀏覽
添加回答
舉報(bào)