I have the following code:
$.get(viewUrl + para, function (data) {
dialogDiv.html(data);
...
});
Is there some way that I can add an error check to this? Something that will call a function if the get fails?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As
$.get()is shorthand for the$.ajax()method, you could just use that:I recommend this option as it (for me at least) seems far better suited for more complex AJAX requests. Sure adding an error callback may not constitute it being complex, but it’s good to know your options.