I'm trying to return JSONP from Symfony2. I can return a regular JSON response fine, but it seems as if the JSON response class is ignoring my callback.
$.ajax({
type: 'GET',
url: url,
async: true,
jsonpCallback: 'callback',
contentType: "application/json",
dataType: 'jsonp',
success: function(data)
{
console.log(data);
},
error: function()
{
console.log('failed');
}
});
Then in my controller:
$callback = $request->get('callback');
$response = new JsonResponse($result, 200, array(), $callback);
return $response;
The response I get from this is always regular JSON. No callback wrapping.
The Json Response class is here:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/JsonResponse.php