I have the following loop to send data to ajax function as json :
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);
}
}
The Result is:
{"department":"2","careerLocation":"1","title":"fd","job":"sa","logo":"sa"}
{"department":"2","careerLocation":"1","title":"sa","job":"sa","logo":"sa"}
what should I do to type json correctly?