Yii Framework Forum: Global Ajax Error Handler - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Global Ajax Error Handler Rate Topic: -----

#1 User is offline   InsaneWookie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 04-September 12

Posted 20 September 2012 - 09:14 PM

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.
0

#2 User is online   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,355
  • Joined: 12-October 09
  • Location:Croatia

Posted 21 September 2012 - 03:24 AM

Currently you need to use the ajaxUpdateError - http://www.yiiframew...ateError-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.
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   InsaneWookie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 04-September 12

Posted 23 September 2012 - 06:02 PM

View PostMaurizio Domba, on 21 September 2012 - 03:24 AM, said:

Currently you need to use the ajaxUpdateError - http://www.yiiframew...ateError-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.
0

#4 User is offline   InsaneWookie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 04-September 12

Posted 23 September 2012 - 09:52 PM

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

#5 User is offline   amaney_kht 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 31-March 14

Posted 31 March 2014 - 03:58 AM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users