M
M
masimka2017-06-16 12:15:32
Kohana
masimka, 2017-06-16 12:15:32

Why does the method accept post data?

honey code

class Controller_Staff_Ajax extends Controller { 
.......
public function action_shop_title()
    {
      if ( Request::initial()->is_ajax() AND HTTP_Request::POST == $this->request->method() )
        {
         echo $this->request->method();
          var_dump($this->request->post('id'));
          var_dump($_POST);
        }
 
    }

outputs zero.
and displays POST I send the request with jquery - content - editable and with the Chrome plugin, advanced rest client does not display anything. What am I doing wrong ? Thank you.
echo $this->request->method();
56ce32f31d3247c7a416989db18bb516.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
ivankomolin, 2017-06-16
@masimka

1. Comment out everything in the method, type var_dump('+++'); and get +++ to appear in the browser and then in the specified program.
2. Then write var_dump($_POST) and send data from advanced rest client POST (for example, via Data form).
3. Make sure that the condition is met (Request::initial()->is_ajax() AND HTTP_Request::POST == $this->request->method()) Most likely it will require changing the Request Header.
4. Return your code)

M
masimka, 2017-06-28
@masimka

All right. I did not take into account that the method that receives POST in before() checks for authorization, and then passes the work to the controller method, which in turn works with the variable passing it to the model method. In short, I forgot to update the tab so that the authorization worked.)))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question