Imagine you have site with many ajax requests. There is a change in design. Now before each request you want to display some custom loading gif. You neeed to change all the code where there is an ajax request or you can use proxy pattern.
var proxied = jQuery.ajax; // Preserving original function
jQuery.ajax = function() {
jQuery("#loading").dialog({modal: true});
return proxied.apply(this, arguments);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…