views:

202

answers:

3

My intuitive response to this question would be ,"This is so stupid that I can't continue having this conversation." However:

Is there any way to hook all javascript function calls within my module? I'd like to find a convenient way of showing "loading blah...", "done..." messages when performing AJAX calls without having to explicitly place a call to a notification method in every AJAX method.

Also, is there any convenient way to set up a global exception handler in javascript?

It's perfectly possible, of course, to eliminate the need for either of these things by performing correct exception handling in every applicable method, but it would be nice to have a global "Whoops!" method to happily catch anything that managed to slip through due to programmer (ie, me) error.

Working in C#/ASP.NET if it matters or if there's a server-side gadget that could make this easier.

+1  A: 

window.onerror will catch all of the errors. That's how Firebug and others work.

As for "every ajax method" you should just have 1 reusable ajax method, and have it be in charge of updating your status message.

lod3n
+1  A: 

If you only have ajax calls actually being made in one place, where the open and send commands are, then you can put in some logging, or notification there.

If you are using jquery, or some library that supports selectors, you can bind to the events of many objects.

The exception part was already answered.

James Black
A: 

You can look at all objects via function show_props(obj, obj_name) { var result = "" for (var i in obj) result = obj_name "." i " = " obj[i] "\n" return result; } That is from http://www.memestreams.net/users/acidus/blogid10323750/