A useful monkey patch for jQuery's
- Calls a user-defined Fn when an async operation has started and completed.
- Intended for cases when there are lots of existing
$.get or $ .post operations, and it’s not manageable to bring in an $.ajax setup.
async_mp.js currently supports the following code signatures:
$.get(url).done(function(response)
{
//do something with 'response'
});
$.get(url, function(response)
{
//do something with 'response'
});
$.post(url, {foo: "bar"}).done(function(response)
{
//do something with 'response'}
);
$.post(url, {foo: bar"}, function(response)
{
//do something with 'response'}
);
Include the script AFTER jQuery, and define at top level (window) two Fns:
begin_async_op
end_async_op
Ex:
function begin_async_op()
{
$("#loading_div").css("display", "block");
}
function end_async_op()
{
#("#loading_div").css("display", "none");
}
After jQuery has finished loading , call async_mp() to get the patched versions of