Welcome Guest, Not a member yet? Register   Sign In
"isAJAX()" method always return false;
#1

(This post was last modified: 09-29-2018, 07:42 AM by titounnes.)

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 
namespace App\Controllers\Api;

use function 
time;
use 
CodeIgniter\API\ResponseTrait;
use 
CodeIgniter\Controller;
use 
CodeIgniter\HTTP\ResponseInterface;

final class 
Test extends Controller 
{
 
   use ResponseTrait;

 
   public function index(): ResponseInterface
    
{
 
       return $this->respond([
 
           'ack' => time(),
 
           'req' => $this->request->getPost('foo'),
 
           'head' => $this->request->getServer('HTTP_BEARER'),
 
           'ajax' => $this->request->isAJAX(),
 
           ]);
 
   }

Reply


Messages In This Thread
"isAJAX()" method always return false; - by titounnes - 09-29-2018, 07:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB