php - undefined data result ajax symfony

one text

Solution:

first check, if your $products returns anything by e.g. dumping it: dump($products);

if yes, try to return a JsonResponse

use Symfony\Component\HttpFoundation\JsonResponse;


// encode your $products on the fly
$response = new JsonResponse($products);

// if the data to send is already encoded in JSON
$response = JsonResponse::fromJsonString('$jsonContent');

Source