开发者

PHP returns HTML rather than JSON

I am trying to get json response from the server. But jquery only g开发者_如何学Goot html. By the way I am using zend framework. Any idea?

Thanks


You could use:

    $this->_helper->layout->disableLayout();

or

    $this->_helper->viewRenderer->setNoRender();

and then output the JSON.


$this->_helper->json($myArray);

Will disable layout and handle everything including header for you ;)


Just a guess:

You need to use contextSwitch() action helper, or disable the view and layout rendering and send the JSON response manually.


  $json = Array(
    "name"=>"value"
  );
  header("Content-type: application/json");
  echo json_encode($json);  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜