// show loading animation and errors inside the container that is being replaced
// https://grosser.it/2012/06/21/jquery-load-extension-to-indicate-loading-and-errors
$.fn.responsiveLoad = function(url, callback){
var loading = '
';
var $container = $(this);
$container.html(loading).load(url, function(response, status, xhr){
if (status == "error") {
$container.html("Error:" + xhr.status + " " + xhr.statusText);
} else {
if(callback) callback(response, status, xhr);
}
});
};
Like this:
Like Loading...
Related