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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -