I have this function Javascript
( Post Ajax
) that when it gives exception in post
it is passing if (r != "") {
.
I needed to capture that was an exception and treat it out of if
.
JavaScript
function AsyncAlert() {
$.post("MinhaUrl/AsyncMessage", {}, function (r) {
if (r != "") {
mensagemAlert(r);
}
});
}
C#
public JsonResult AsyncMessage()
{
if(TemMensagemNovaAsync())
return Json(_msgAsync);
else
return Json("");
}
Consider that I need to catch the exception if I have not been able to connect to the backend. In other words, the url server crashed, the url was not available
What is the best way for me to review this?
Note: My language is C#
.