我在单击 anchor 标记时进行 ajax 调用: 我有许多数组作为输出。 但我无法在 HTML 表格中显示这些数组。请建议我如何实现这一目标。
function getdetail(cid)
{
var cid = cid;
var xmlhttp = new XMLHttpRequest();
var url = "c_detail.php";
var params = "cid="+cid;
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById('cdetail').innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET",url+"?"+params,true);
xmlhttp.send();
}
My array output looks like this :
Array ( [0] => Array ( [id] => 5088 [start] => first [end] => last [ad_start] =>ad_first [ad_end] => ad_last [cid] => 79 [car] => Dialog ) )
当然,这会将数据显示为没有任何格式的数组列表。我想将其显示为 HTML 表格 任何帮助将不胜感激 !!! 提前致谢
最佳答案
好的,我建议您使用现有的库,例如 datatables ,你必须通过json_encode($array)
函数将php数组转换为json数据。
关于php - 无法在 HTML 表格中显示来自 ajax 的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12460834/