-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[update] add on error handlers for jquery ajax events #186
Conversation
What about using a global error handler, instead of duplicating this code ? |
3c519ff
to
17f6a5d
Compare
@patatepartie ah, thanks for the suggestion. I tried with a sample fiddle here @ https://jsfiddle.net/16ccx3uf/. seems good as we can still have custom error handlers in specific ajax calls while having the global error handler executed as well :) updated the code as such. |
@@ -8,6 +8,12 @@ | |||
} | |||
}; | |||
|
|||
// register common error handler on Ajax errors / failures | |||
function logError(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can inline this method, since it's not used anywhere else.
If you think the logError
name is useful, you can write:
$(document).ajaxError(function logError(err) {
console.error(err)
});
Otherwise, this is enough:
$(document).ajaxError(console.error);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(document).ajaxError(console.error);
Seems good for now 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought of that as well initially as well, but decided against it somehow (based on second-guessing myself). will do so!
17f6a5d
to
b46a558
Compare
LGTM 🎉 |
LGTM, thanks @kelvintaywl |
…x-fail [update] add on error handlers for jquery ajax events
This is just an attempt to add some handling on when the ajax requests fail.