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){
Because the option.success is used before ajaxSend. When it was used,it was added to the Deferred Object.
After that,you change the option.success, nothing will happen.
So, you must change it before is was used. the process is:
$.ajaxPrefilter -- $.fn.ajaxStart(if needed) -- option.beforeSend --
USE option.success and option.error and option.complete --
$.ajaxTransport -- $.fn.ajaxSend -- send the actual request --
option.dataFilter -- fire the success/error callbacks --
$.fn.ajaxSuccess/$.fn.ajaxError -- fire the complete callbacks --
$.fn.ajaxComplete -- $.fn.ajaxStop(if needed)
So, you can change the option.success in "$.ajaxPrefilter" or "option.beforeSend".