how to overwrite the success function via JQuery ajaxSend event

前端 未结 3 953
走了就别回头了
走了就别回头了 2021-01-05 12:45

I am trying to overwrite the success function upon ajaxsend event but it doesnt work here is the code:

    $(document).ajaxSend(function(event,xhr,options){
         


        
3条回答
  •  遥遥无期
    2021-01-05 13:14

    You could use closures to accomplish what you need:

    function closure(handler) {
        return function(ev, xhr, options) {
            console.log("start");
            handler(ev, xhr, options);
            console.log("stop");
        }
    }
    
    $(document).ajaxSend(closure(function(ev, xhr, options) {
        console.log("hello");
    }));
    

提交回复
热议问题