how to retrieve data sent by Ajax in Cakephp?

后端 未结 2 382
时光说笑
时光说笑 2021-01-18 20:09

I have been stuck at this problem for a whole day. What im trying to do is to send 2 values from view to controller using Ajax. This is my code in hot_products

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-18 20:38

    If you method is POST:

     if($this->request->is('ajax'){
    $this->request->data['start_time'];
    $this->layout = 'ajax';
    }
    

    OR

    public function somefunction(){  
    $this->request->data['start_time'];  
    $this->autoRender = false;
    

    ANd if method is GET:

     if($this->request->is('ajax'){
    $this->request->query('start_time');
    $this->layout = 'ajax';
    }  
    

    OR

    public function somefunction(){  
    $this->request->query('start_time');  
    $this->autoRender = false;
    

提交回复
热议问题