![]() |
"isAJAX()" method always return false; - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31) +--- Thread: "isAJAX()" method always return false; (/showthread.php?tid=71832) |
"isAJAX()" method always return false; - titounnes - 09-29-2018 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 RE: "isAJAX()" method always return false; - unodepiera - 09-29-2018 (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; ![]() RE: "isAJAX()" method always return false; - titounnes - 09-30-2018 (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. |