【发布时间】:2012-05-30 03:48:55
【问题描述】:
在我的 ajax 代码中:
$.ajax({
url: CI_ROOT + "isUserExist",
type: "GET",
data: {recepient: recepient},
success: function(r) {
console.log(r)
}
})
给我一个输出 [{"records":"1"}][{"records":"1"}] 所以我通过添加 dataType:" 将其解析为 json json" 在我的 ajax 代码中。但是当我解析它时,它没有给我输出,而是在 try-catch-block 上出错。
如何让它显示为对象? 在我的 PHP 代码中,我是这样做的:
for ($i = 0; $i < count($matches[0]); $i++) {
echo json_encode($this->searchmodel->doesUsersExists($matches[0][$i]));
} //gets the user id of the user from a given string.
【问题讨论】:
标签: php javascript json