我有以下循环将数据作为json发送到ajax函数:
foreach($careers->getItems() as $item){
if($item->getDepartment()==$departmentID && $item->getLocation()==$locationID) {
$arr = array('department' => $item->getDepartment(), 'careerLocation' => $item->getLocation(),
'title' => $item->getTitle(), 'job' => $item->getJob(), 'logo' => $item->getLogo());
echo json_encode($arr);
}
}
结果是:
{"department":"2","careerLocation":"1","title":"fd","job":"sa","logo":"sa"}
{"department":"2","careerLocation":"1","title":"sa","job":"sa","logo":"sa"}
我该怎么做才能正确输入json?