I have a problem with Symfony JsonResponse Component that I used in my app.
JsonResponse always return status code 200.
return new JsonResponse([], JsonResponse::HTTP_BAD_REQUEST);
and jquery ajax
$.ajax({
type: 'DELETE',
url: BASE_URL +'/api/cart',
data: {id: id},
dataType: 'json',
success: function (response) {
waitResponse.resolve(response);
},
error: function (error, a, b) {
waitResponse.reject(error);
}
})
Response always evaluate to error with msg "parseerror", but status code is 200. If I remove dataType: 'json', then is always in success. Does anybody know how to fix this problem.
Thanks