Cakephp 3 : How to receive get request data? -
i have written ajax send search key, have tried below code
$.ajax({ method:'get', url:'<?php echo router::url(['action' => 'product_search']); ?>', data:{search:search}, success: function(data) { $('.fetch-data').html(data); } });
then have received in product controller
if ($this->request->is(['get'])) { $search = $this->request->data('search'); }
here $search
null. if use post
in here it's working fine. how can receive data method ?
used below code in product controller
if ($this->request->is(['get'])) { $search = $this->request->query('search'); }
cookbook > controllers > request & response objects > query string parameters
Comments
Post a Comment