Home › Forums › JavaScript › Try/catch inside JQuery $.ajax call › Reply To: Try/catch inside JQuery $.ajax call
July 23, 2014 at 6:25 pm
#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.