我正在尝试在网页上显示数据库查询的结果。我正在使用下面的 JQUERY 脚本通过 php 脚本将数据作为 JSON 数组获取。
由于某种原因,我无法弄清楚,网页。为空白。请注意,警报显示数据正在正确传递给 $.each 循环。
谁能告诉我我做错了什么??
谢谢克里斯
_
查询脚本
功能项目数据(){
var data = '';
$.ajax(
{
url:"projectdata.php",
type: "POST",
dataType: 'JSON',
cache: false,
success:function(data)
{
$( "#projectList" ).insertAfter('<tbody>' +
$.each(data, function(indx, value)
{
'<tr><td>' + data[indx].project_id + '</td>' +
'<td>' + data[indx].dept + '</td>' +
'<td>' + value.projName + '</td>' +
'<td>' + data[indx].notes + '</td>' +
'<td>' + data[indx].dates + '</td>' +
'<td>' + data[indx].status + '</td>' +
alert("ID: " + value.project_id + " " + "DEPT: " + data[indx].dept);
} //end function
) //end each
) //end After
} //end success
}); //end ajax
} //结束项目数据
HTML 脚本
现有项目:
< table id="projectList">
< thead>
< tr class="success">
< th class="span1">PROJECT ID < /th>
< th class="span2">SCHOOL / DEPT < /th>
< th class="span1">PROJECT < /th>
< th class="span3">DESCRIPTION / PROJECT NOTES < /th>
< th class="span1">APPROX DATES < /th>
< th class="span1">STATUS < /th>
< th class="span1">USER</th> < /tr>
< /thead>
< tbody>
< !-- RESULTS FROM JQUERY/PHP GOES HERE -->
< /tbody>
< /table>