I am trying to use AJAX to populate my dropdown list and I am returning a 404 with error message from my controller, and Ajax is not catching it...
My return at the controller is
return Response()->json(array('error' => '404 car type not found'), 404);
And here is my JS
$('document').ready(function () {
$('#car_type').bind('changed.bs.select', function () {
$.ajax({
type: 'POST',
url:'carclass/'+$('#car_type').val(),
dataType: 'json',
error: function(XMLHttpRequest, textStatus, errorThrown){
alert('status:' + XMLHttpRequest.status + ', status text: ' + XMLHttpRequest.statusText);
},
success: function( json ) {
$.each(json, function(i, obj){
$('#car_class').append($('<option>').text(obj.name).attr('value', obj.id));
});
$('#car_class').selectpicker('refresh');
}
});
});
});
It is returning
GET http://localhost:8000/ads/cartype/2 404 (Not Found)