"isAJAX()" method always return false; |
I tried to create an API with a script like the one below. when I run it with $.ajax , the application always returns the "false" value in the isAJAX method. Whats wrong?
Thanks before. PHP Code: <?php
(09-29-2018, 07:41 AM)titounnes Wrote: I tried to create an API with a script like the one below. when I run it with $.ajax , the application always returns the "false" value in the isAJAX method. Whats wrong? In my case all works fine. Header on welcome_message.php Code: <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script> Routes.php PHP Code: $routes->get('/ajax-html', 'Home::ajaxOrHtml'); Controller Home.php PHP Code: <?php namespace App\Controllers; (09-29-2018, 11:32 AM)unodepiera Wrote:(09-29-2018, 07:41 AM)titounnes Wrote: I tried to create an API with a script like the one below. when I run it with $.ajax , the application always returns the "false" value in the isAJAX method. Whats wrong? Thanks for your reply. Solve with add "X-Requested-With": 'XMLHTTPRequest' in header. |
Welcome Guest, Not a member yet? Register Sign In |