There is such a code
$.post(url, function (data) { if (typeof callback == 'function') { callback(data); } }) .done(function (response) { console.log(response); }) .fail(function () { alert("error"); }); The request goes to the controller url = blah blah.json
If the request is successful, everything works fine. It is necessary to process 415 responce In the controller, the following code:
return new Response(Response::HTTP_UNSUPPORTED_MEDIA_TYPE); In Route defaults = {"_format"="json"}, requirements = {"_format"="json"} ,
I get the following error in the browser:
Uncaught TypeError: Cannot use 'in' operator for search for 'length' in 415
In general, I overcame the error return new Response('',Response::HTTP_UNSUPPORTED_MEDIA_TYPE);
And how to handle exactly 415 response? so that the error does not fall into the console