I've been trying to setup an Ajax Call in Cakephp 3.0.11. I've followed the explanation here : http://book.cakephp.org/3.0/en/views/json-and-xml-views.html
Json enabled in routing (but i'm not really sure that's usefull) :
$routes->extensions(['json', 'xml', 'html']);
I've setup my exemple in controller :
$returnObject = new ObjectReturn();
$this->set('returnObject', $returnObject);
$this->set('_serialize', ['returnObject']);
But when I make my ajax call, I've got :
{
"message": "Template file \Pages\\score.ctp\ is missing.",
"url": "\/pages\/score",
"code": 500
}
If I create the page, he juste render me some html, with default.ctp as a layout. What's wrong here ?
Thanks a lot !
RequestHandlerComponentin your controller as explained here? - Holtjsonview using extensions and request handling, your url needs to use the.jsonextension, such as/pages/score.json. - HoltAs of 3.1.0 AppController, in the application skeleton automatically adds '_serialize' => true to all XML/JSON requests. You will need to remove this code from the beforeRender callback if you want to use view files.from book.cakephp.org/3.0/en/views/… - Steve Tauber