开发者

PHP returns HTML rather than JSON

开发者 https://www.devze.com 2023-01-25 12:57 出处:网络
I am trying to get json response from the server. But jquery only g开发者_如何学Goot html. By the way Iam using zend framework. Any idea?

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

精彩评论

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