MDL-42989 JavaScript: Check result of navigation IO requests before reporting errors

When making a request which fails, we need to ensure that the AJAX query
was not aborted before displaying the error.

This ensures that if the navigation tree is being requested at the same
time as a page load is being processed, the abortion of the AJAX request is
not displayed before the page reloads.
This commit is contained in:
Andrew Nicols 2013-12-03 14:36:40 +08:00 committed by Dan Poltawski
parent ed52eb4c88
commit 5259c6b402
4 changed files with 21 additions and 15 deletions

View file

@ -679,11 +679,13 @@ BRANCH.prototype = {
}
Y.log('AJAX loading complete but there were no children.', 'note', 'moodle-block_navigation');
} catch (error) {
// If we got here then there was an error parsing the result.
Y.log('Error parsing AJAX response or adding branches to the navigation tree', 'error', 'moodle-block_navigation');
Y.use('moodle-core-notification-exception', function () {
return new M.core.exception(error).show();
});
if (outcome && outcome.status && outcome.status > 0) {
// If we got here then there was an error parsing the result.
Y.log('Error parsing AJAX response or adding branches to the navigation tree', 'error', 'moodle-block_navigation');
Y.use('moodle-core-notification-exception', function () {
return new M.core.exception(error).show();
});
}
return false;
}

View file

@ -675,10 +675,12 @@ BRANCH.prototype = {
return true;
}
} catch (error) {
// If we got here then there was an error parsing the result.
Y.use('moodle-core-notification-exception', function () {
return new M.core.exception(error).show();
});
if (outcome && outcome.status && outcome.status > 0) {
// If we got here then there was an error parsing the result.
Y.use('moodle-core-notification-exception', function () {
return new M.core.exception(error).show();
});
}
return false;
}

View file

@ -677,11 +677,13 @@ BRANCH.prototype = {
}
Y.log('AJAX loading complete but there were no children.', 'note', 'moodle-block_navigation');
} catch (error) {
// If we got here then there was an error parsing the result.
Y.log('Error parsing AJAX response or adding branches to the navigation tree', 'error', 'moodle-block_navigation');
Y.use('moodle-core-notification-exception', function () {
return new M.core.exception(error).show();
});
if (outcome && outcome.status && outcome.status > 0) {
// If we got here then there was an error parsing the result.
Y.log('Error parsing AJAX response or adding branches to the navigation tree', 'error', 'moodle-block_navigation');
Y.use('moodle-core-notification-exception', function () {
return new M.core.exception(error).show();
});
}
return false;
}