Setting the filter for ajax queries in the class Filters does not work |
The documentation says that you can customize filters for specific requests (post, get, put etc) class - Filters property - $methods. It is also said that you can do the same for ajax queries and from the console query by setting the key ajax or cli.
But this does not work for the ajax key, I get into the filter if I put the post key. HTTP header 'X-Requested-With': 'XMLHttpRequest' avalaible. isAjax() return true. What could be the problem?
Are you sending the 'X-Requested-With' header in your ajax code?
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
You need to send that header with JavaScript, not from the controller.
jQuery has a header method for doing this. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-20-2020, 05:43 AM)InsiteFX Wrote: You need to send that header with JavaScript, not from the controller.Here is my code js: Code: let button = document.querySelector('input[type=button]'); PHP Code: public function ajax() (11-22-2020, 07:16 AM)MGatner Wrote: https://github.com/codeigniter4/CodeIgni...ssues/2314Now it is more or less clear. Thank you for the information |
Welcome Guest, Not a member yet? Register Sign In |