Answer the question
In order to leave comments, you need to log in
Why is JsonResponse not returning anything?
I decided to add a couple of symfony components to codeigniter. I came across the fact that return new JsonResponse(['data' => rand(5, 100)]); does not work.
Who can tell why?
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
class Ajax extends Controller
{
private $request;
public function __construct()
{
header('Content-Type: application/json');
$this->request = Request::createFromGlobals();
}
public function index()
{
return new JsonResponse(['data' => rand(5, 100)]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question