Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Try/catch inside JQuery $.ajax call Reply To: Try/catch inside JQuery $.ajax call

#176266
noahgelman
Participant

I believe the reason why your try/catch doesn’t work is because code the Ajax success/error callbacks are outside the scope of the try/catch. The success/error callbacks can’t even read variables stated outside the Ajax call.

Here is an example: http://codepen.io/anon/pen/Adewv

So how do you better track what function sends out errors?

I haven’t used it before but I believe you can use .ajaxError() to help track these things. Here is jQuery’s page on it. Maybe it’ll help you out.

http://api.jquery.com/ajaxError/