Extending jQuery ajax success globally

后端 未结 5 1940
庸人自扰
庸人自扰 2021-01-03 03:19

I\'m trying to create a global handler that gets called before the ajax success callback. I do a lot of ajax calls with my app, and if it is an error I return a specific st

5条回答
  •  臣服心动
    2021-01-03 03:38

    Here is the most basic example:

    $.ajaxSetup({
        success: function(data){  
            //default code here
        }
    });
    

    Feel free to look up the documentation on $.ajaxSetup()

提交回复
热议问题