我发出ajax请求,并以json形式返回,但是每次都会给我“语法错误:json在位置0处出现意外令牌A”,我将在下面发布我的ajax代码,谢谢。
$.ajax({
url: "/report/get-judge-optionals", type:'GET', dataType:'json', cache:true,
data: {
inputRole: $(this).attr('data-role'),
court: selected.data("court"),
judge: selected.data('value'),
master: fields.master,
report_id: fields.report_id
},
success: function(data, textStatus, jqXHR) {
},
beforeSend: function(jqXHR) {},
error: function(jqXHR, textStatus, errorThrown) {alert(errorThrown);},
complete: function(jqXHR,status) {}
});
控制器功能返回的是
Zend\View\Model\JsonModel Object
(
[captureTo:protected] =>
[jsonpCallback:protected] =>
[terminate:protected] => 1
[children:protected] => Array
(
)
[options:protected] => Array
(
)
[template:protected] =>
[variables:protected] => Array
(
[0] => Array
(
[proc_cat_id] => 4
[0] => 4
[proc_cat_name] => Class Action (343)
[1] => Class Action
[dec_count] => 343
[2] => 343
)
[1] => Array
(
[proc_cat_id] => 2
[0] => 2
[proc_cat_name] => Action (323)
[1] => Action
[dec_count] => 323
[2] => 323
)
)
[append:protected] =>
)
再次感谢
答案 0 :(得分:3)
您似乎收到的响应是print_r输出,您应该使用
echo json_encode($object)
此外,如果上述方法不起作用,我会寻找服务器脚本输出的UTF8-BOM字符