后端getdata.php代码如下:<?php
include('./conn/conn.php');
$query="select id,content,pubtime,imgsrc,thumbsrc from messages order by id desc";
$result=mysql_query($query);
while( $row = mysql_fetch_array( $result ) ) {
$json[] = $row;
}
echo json_encode($json);
exit;
?>
前端我想这么显示:
前端javascript代码:
function get_data()
{
$.ajax({
url: 'getdata.php',
datatype:'json',
success: function(data) {
var data = eval("(" + data + ")");
... //然后这个地方应该怎么写
}
}
}
});
}
setInterval("get_data()",3000);