duanri1985
2018-06-26 16:06
浏览 115
已采纳

ajax,语法错误:位于0的json中的意外标记A.

I make an ajax request, and returned in json form, but it gives me "syntax error: unexpected token A in json at position 0" every time, I will post my ajax code below, thanks.

$.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) {}
    });

what is returned from controller function is

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] => 
)

Thanks again

图片转代码服务由CSDN问答提供 功能建议

我发出ajax请求,并以json格式返回,但它给出了“语法错误:意外的令牌A in json在位置0“每次,我都会在下面发布我的ajax代码,谢谢。 </ p>

  $。ajax({
 url:“/ report / get-judge-optionals”,type:'GET',dataType:'json',cache:true,  
 data:{
 inputRole:$(this).attr('data-role'),
 court:selected.data(“court”),
判断:selected.data('value'),
  n master:fields.master,
 report_id:fields.report_id 
},
 success:function(data,textStatus,jqXHR){
 
},
 beforeSend:function(jqXHR){},
 错误:function(jqXHR,textStatus,errorThrown){alert(errorThrown);},
 complete:function(jqXHR,status){} 
}); 
 </ code> </ pre> 
 
 <  p>从控制器函数返回的是</ p> 
 
 
  Zend \ View \ Model \ JsonModel Object 
(
 [captureTo:protected] =&gt; 
 [jsonpCallback:protected  ] =&gt; 
 [终止:受保护] =&gt; 1 
 [儿童:受保护] =&gt;数组
(
)
 
 [选项:受保护] =&gt;数组
(
  )
 
 [template:protected] =&gt; 
 [变量:protected] =&gt;数组
(
 [0]  =&GT; 数组
(
 [proc_cat_id] =&gt; 4 
 [0] =&gt; 4 
 [proc_cat_name] =&gt;类操作(343)
 [1] =&gt;类操作
 [dec_count]  =&gt; 343 
 [2] =&gt; 343 
)
 
 [1] =&gt; 数组
(
 [proc_cat_id] =&gt; 2 
 [0] =&gt; 2 
 [proc_cat_name] =&gt;动作(323)
 [1] =&gt;动作
 [dec_count] =&gt;  ; 323 
 [2] =&gt; 323 
)
 
 
)
 
 [append:protected] =&gt;  
)
 </ code> </ pre> 
 
 

再次感谢</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题