I'm making AJAX calls to a server that sometimes return unparseable JSON. The server isn't under my control, so I can't fix that.
function eventFunction(evt) {
$('div#status_bar').show();
$.ajax({
url: 'http://buggyserver.com/api/',
type: 'GET',
data: { 'mode': 'json', 'q': 'get/data' },
dataType: 'json',
success: updateForm
});
}
function updateForm(returned, status) {
if (status == 'success') {
//Update the form here
}
$('div#status_bar').hide();
}
When unparseable JSON is returned, the updateForm
functions does not get called.
How can I, on the client side, ensure that the last line of the updateForm
function gets called to hide the status bar when? I've tried putting try { } catch {}
clauses around both the AJAX call and the updateForm.