我想使用PHP和MySQL查看每一行,但之前我使用XHR实时更新了数据库中的数据。我猜我需要使用Jquery,但我缺乏如何使用的知识。
var html ="";
for (var a=0;a<data.length;a++)
{
var devid =data[a].dev_ID;
var devname =data[a].dev_Name;
var devstatus =data[a].dev_Status;
var reading01 = data[a].dev_Reading01;
var reading02 = data[a].dev_Reading02;
//html += "<tr>";
// html += "<td>"+firstName+"</td>";
//html += "<td>"+lastName+"</td>";
//html += "<td>"+jobTitle+"</td>";
//html += "<td>"+devstatus+"</td>";
//html += "</tr>";
html +='<div class="row mt-2 mb-2 bg-info height" >';
html += '<div class="container-fluid ex3" >';
html +='<div class="row mt-2 mb-2 bg-info height" >';
html += '<div class="col-4">Name:<br>'+devname+'</a></div>';
html += '<div class="col-2">Status<br>'+devstatus+'</div>';
html += '<div class="col-2">Reading 01<br>'+reading01+'</div>';
html += '<div class="col-2">Reading 02<br>'+reading02+'</div>';
html += '<div class="col-2">Status<br>'+devstatus+'</div>';
html += "</div>";
html += "</div>";
html += "</div>";
// html += "<br>";
}
document.getElementById("data").innerHTML = html;
}
答案 0 :(得分:0)
您可以仅使用jquery数据表插件,在其中可以传递“数据”
$('#id').dataTable( {
"aaData": data,
"aoColumns": [
{ "sTitle": "title1" },
{ "sTitle": "title2" },
{ "sTitle": "title3" },
{ "sTitle": "title4"}
]
});