I have this ajax call:
$.ajax({
method: "GET",
url: "/Shipper/getFullAddress",
data: {
postalCode: value
},
dataType: 'json',
success: function(data) {
$('#AddressStreet').val(data.AddressStreet);
$('#AddressNeighborhood').val(data.AddressNeighborhood);
$('#AddressCity').val(data.AddressCity);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
})
Call this method:
[AjaxCall]
public JsonResult getFullAddress(string postalCode) {
try {
var address = getAddressByZipCode(postalCode);
return Json(address, JsonRequestBehavior.AllowGet);
} catch (System.Exception ex) {
return Json(ex.Message);
}
}
I wanted to show the exception message in my view, but my call returns this: