How can I find out if a request was made with AJAX in Kohana 3?

I tried these

request::is_ajax() Request::instance()->is_ajax 

To no avail. I noticed that the public property $is_ajax exists in the request class, but I cannot access this property.

What am I doing wrong?

+4
source share
3 answers

You can also use this:

 if (Request::$is_ajax OR $this->request !== Request::instance()) { .. } 

So you know this is ajax- or ajax-like-request

I use this in my base controller class, so I know whether to display the full or partial view.

+5
source

if someone comes back to this, in Kohana 3.1 now $this->request->is_ajax( ) if you are in the controller.

+9
source

I ended up working with Request::$is_ajax

It seems that they got rid of this function and now rely on a public property.

+3
source

Source: https://habr.com/ru/post/1300260/


All Articles