General ajax handler


Nowadays I have started development in YII framework. I have a little problem and i do not know what is the best solution for my problem. I would like to handle global ajax error in my system. I do not want to write error function in javascript every time if i use ajax call.

My idea that i write a default jquery ajax errer handler script and I regist every time.

For example:


And this regist every time

Anybody know better solution or has better idea? I do not know that YII gives solution for my problem.

Thanks help.