If I have a javascript error outside of a callback, Firebug console prints out the error. However, if I have ant error inside a callback, I will not see any printout.
document.observe('dom:loaded', function() {
// not notified in console
alert(undefinedVariable);
});
// notified in console
alert(anotherUndefinedVariable);
Almost all of my code is inside callbacks, so it is making it hard for me to track down errors. How do I print out every error in the console no matter where the error occurs?
I needed to tell Prototype to not swallow the exceptions.
Ajax.Responders.register({
onException: function(request, exception) {
(function() { throw exception; }).defer();
}
});
您可以尝试显式打印到控制台-window.console.log(... something ...)应该可以在任何地方工作。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.