<?php
include ('config.php');
$stringData = $_POST['dataString'];
$sql=mysql_query("SELECT * FROM comments WHERE post_id_fk='$stringData'");
while($row=mysql_fetch_array($sql)) {
$user=$row['user_id'];
$time=$row['time'];
$comment=$row['comment_content'];
$respond=array(
'user'=>$user,
'time'=>$time,
'comment'=>$comment
);
echo json_encode ($respond);
}
?>
我有这个脚本,但无法弄清楚,这里什么不起作用,为什么响应不是 JSON?
在 Firebug 中显示响应:
{"user":"890","time":"2013-08-15 20:34:02","comment":"What's up?"}
{"user":"878","time":"2013-08-15 23:35:45","comment":"opa"}