我在 codeigniter 框架内工作,并在页面加载时发出以下 ajax 请求:
$.ajax({
url: '/beta/images/loadImages',
type: 'POST',
dataType: 'json',
data: {id: id},
success: function(json, textStatus, xhr) {
alert('success');
}
}, error: function(json, textStatus, errorThrown) {
alert(errorThrown);
}
});
强文本
public function loadImages()
{
$galleryID = $this->input->post('id');
$data = array('images' => $this->image_gallery->get_slideImages($galleryID) );
echo json_encode($data);
}
最后是模型
public function get_slideImages($galleryID)
{
$this->db->select('id');
$this->db->where('galleryID', $id);
$query = $this->db->get('image_images');
$result = $query->result();
return $result;
}
Chrome 中的 JSON 返回
{"images":[{"id":"34","galleryID":"57","clientRef":"205","imageName":"769074051374530545.jpg","orgName":"P9180021.jpg","order":"0","timestamp":"1374530546"}]}
该错误仅发生在 iPad 和 iPhone 上。SyntaxError: JSON Parse Error: Unrecognized token '<' 关于这个有什么想法吗?