1
I have this call ajax:
$.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);
}
})
who calls 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 flame returns this:
It seems that json is wrong somewhere
– Lucas
yes, and I don’t know where it could be.
– Vinicius
click on that 65,524 that appears on the console to see what happened on json
– Lucas
Man, this code of yours, I don’t think it’s gonna behave the way you expect it to. There in javascript, as you treat the error on the server, will not fall into the "error" function of ajax. I will post an answer explaining the error.
– André Luis Marmo