Global Ajax Error Handler

I’ve been trying to register a global ajax error handler for my site but I think there is an issue in the jquery.yiigridview.js that is preventing me from getting it working robustly. And possibly other widget javascript implementations as well.

I can regeister a global or default error handler with either


$(document).ajaxError(function (event, xhr, ajaxOptions, thrownError) { /* some code */ });

or


$.ajaxSetup({

   error: function (event, xhr, ajaxOptions, thrownError) { /* some code */ }

});

And this works fine except with a CGridView widget. When an error occurs it uses its own error handler. Which either gets called before the global error handler (first example) or over writes the error handler (second example)

What I think should happen is the update ajax request in jquery.yiigridview.js (Line 263) should not define a error function if a default one has been setup.

Also the line 265


$grid.removeClass(settings.loadingClass);

should be moved into the complete function of the ajax call.

Currently you need to use the ajaxUpdateError - http://www.yiiframework.com/doc/api/1.1/CGridView#ajaxUpdateError-detail

Yes the line 265 is the same as line 251 and they could be moved to complete().

If you have time, you can try to make a working solution for your case and post it on github.

Cheers.

I ended up setting ajaxUpdateError to an empty function. That suppresses the default javascript alert.

Means I need to set it for every CGridView though.

Hopefully I will get a chance to have another look at it and possibly create a patch sometime this week.

I just realised the I can put the ajaxUpdateError in the config file to set it as default for all GridViews.

Would you please provide the solution of how to put the ajaxUpdateError in the config file, i really need it<br />

thanks in advanced