dongqingchan2385 2015-01-08 07:53
浏览 69
已采纳

无法从Yii中的响应ajaxLink获取json

I have a ajaxLink what send request to controller, where I return encoded json string:

return CJSON::encode(array(
            'up' => ...,
            'down' => ...,
        ));

In view, ajaxLink attributes:

'dataType' => 'json',
'success'  => 'js: function(data) {
     console.log(data); // equal to null
 }'

What I am doing wrong ?

  • 写回答

1条回答 默认 最新

  • doumanshan6314 2015-01-08 08:02
    关注

    Try this:

    header('Content-type: application/json');
    echo CJSON::encode(array(
                'up' => ...,
                'down' => ...,
            ));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?