CakePHP2系を利用して、JSON形式のデータをVIEW側が受け取る方法 環境 CakePHP 2.1.2 PHP 5.3.10 ResponseオブジェクトのbodyにJSONデータをセットしてVIEW側に返却 class HogesController extends AppController { public function hoge() { $this->autoRender = false; $json = array('json_data'=>array('key01'=>'data01', 'key02'=>'data02')); return new CakeResponse(array('body' => json_encode($json))); } } jQuery.ajax() の dataType を 'json' として受け取るデータを JSON データ
![CakePHP2系でJSON形式のデータをjQueryが受け取る - Qiita](https://cdn-ak-scissors.b.st-hatena.com/image/square/cff2945de9130c3c5873960926fa8ceeae57a730/height=288;version=1;width=512/https%3A%2F%2Fqiita-user-contents.imgix.net%2Fhttps%253A%252F%252Fcdn.qiita.com%252Fassets%252Fpublic%252Farticle-ogp-background-412672c5f0600ab9a64263b751f1bc81.png%3Fixlib%3Drb-4.0.0%26w%3D1200%26mark64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZ3PTk3MiZoPTM3OCZ0eHQ9Q2FrZVBIUDIlRTclQjMlQkIlRTMlODElQTdKU09OJUU1JUJEJUEyJUU1JUJDJThGJUUzJTgxJUFFJUUzJTgzJTg3JUUzJTgzJUJDJUUzJTgyJUJGJUUzJTgyJTkyalF1ZXJ5JUUzJTgxJThDJUU1JThGJTk3JUUzJTgxJTkxJUU1JThGJTk2JUUzJTgyJThCJnR4dC1hbGlnbj1sZWZ0JTJDdG9wJnR4dC1jb2xvcj0lMjMxRTIxMjEmdHh0LWZvbnQ9SGlyYWdpbm8lMjBTYW5zJTIwVzYmdHh0LXNpemU9NTYmcz03MzkwZTU1NDI2MDRmM2I0NjlmMjA5ZjI5NDk1MWU0OQ%26mark-x%3D142%26mark-y%3D57%26blend64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZoPTc2Jnc9NzcwJnR4dD0lNDBTZWlSZWkmdHh0LWNvbG9yPSUyMzFFMjEyMSZ0eHQtZm9udD1IaXJhZ2lubyUyMFNhbnMlMjBXNiZ0eHQtc2l6ZT0zNiZ0eHQtYWxpZ249bGVmdCUyQ3RvcCZzPTE0ZDJlZGRmMmNmZThjMTM1ZDY5NDhlMThlZTdlMTI5%26blend-x%3D142%26blend-y%3D486%26blend-mode%3Dnormal%26s%3Db83210f362c451b881385a1013957d7d)