0
I have this function Javascript
(Post Ajax
) that when the post
she’s passing theif (r != "") {
.
I needed to capture what was an exception and treat her out of the 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 capture the exception if I haven’t been able to connect to the backend. In other words, the url server crashed, the url was not available
What better way for me to review this?
Observing: my language is C#
.
Send request for what type of language? if you want to treat what for example, cites problems?
– novic
I am using C#
– Bruno Heringer
Bruno can be made a return with the exception you gave on the server, a suitable framework
true
orfalse
, it is so nothing complicated, but at the same time I was in doubt because Mistakes can be several– novic
But true or false comes in the "r" parameter in the case? I imagined something like the ajax post Success...
– Bruno Heringer
Bruno I can return anything by programming language, but, there is a doubt for example I can return like this
r.success = true
No problems quietly, but, it’s undefined as you want it to be returned. I can return the complete exection, I do not know if it is valid for your context... understood?– novic
Oh yes... I understood what you meant. My concern is not in the backend, because there is already treated. The exception I refer to is for example failed to do the post in the URL.
– Bruno Heringer
Post your full javascript code and full backend please.
– novic
Even when he gives some exception he enters that function?
– Jéf Bueno
Virgilio, posted on.
– Bruno Heringer
jbueno, exactly what I want. Knowing q he could not enter the backend function.
– Bruno Heringer
So you want to treat the exceptions, Isn’t it? What I want to know is whether even when some Exception pops into the server side the client-side function is running. 'Cause if so, there’s something else wrong.
– Jéf Bueno
@jbueno, the server is already with the treatment not to burst exceptions. The only Exception that could pop up in this case is if the post could not access the URL. ie, some exception in the attempt to post.
– Bruno Heringer