Hooking a function call after another asynchronous function call-jQuery

Hooking a function call after another asynchronous function call-jQuery

Fixing bugs has always been day-today tasks for an IT professional. I believe in releasing patches for the bugs in a separate module rather than in the bugged module. This design initially looks weird as to why not correcting the bug at its concerned point, this approach can also be followed but then it involves complete application testing and not module level testing.

Ok, lets come come to our point where in a certain page we need to solve an asynchronous javascript function. So, instead of teasing the original module lets release an independent module that will correct the bugs and hook this function call after our asynchronous function call.

$.when($.ajax(asyncFunction())).then(function () {
    	patchForBug();
	});

So even though our bugged function asyncFunction() is an asynchronous function, our patch function patchForBug() will always be called after asyncFunction() function.