我差不多完成了使用ajax发表评论的教程,但我收到了这个错误,我无法找到答案!未捕获的SyntaxError:意外的令牌< ... SyntaxError:JSON.parse:JSON数据行的意外字符
comment_insert.php ((应将回调发送到的文件))
if(class_exists('Comments') && class_exists('Subscribers'))
{
$userInfo= Subscribers::getSubscriber($userId);
if($userInfo == null)
{
$std->error = true;
}
$commentInfo= Comments::insert($comment , $userId);
if ($commentInfo == null)
{
$std->error = true;
}
$std->user = $userInfo;
$std->comment = $commentInfo;
}
echo json_encode($std);
comment_insert.js
$.post("comment_insert.php",
{
task: "comment_insert",
userId: _userId,
comment: _comment
}
)
.success(function(data)
{
//task: insert html into the ul/li
comment_insert($.parseJSON(data));
console.log("ResponseText: " + data);
});