/ Published in: jQuery

And how you do this?
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// wrapper function jQuery.ajaxLoadingWrapper = function(load, loading, ajaxOptions) { $.ajax($.extend({ beforeSend: function(jqXHR, settings){ $(load).hide(); $(loading).show(); if (ajaxOptions.beforeSend) { ajaxOptions.beforeSend(jqXHR, settings); } }, complete: function(jqXHR, textStatus){ $(loading).hide(); $(load).show(); if (ajaxOptions.complete) { ajaxOptions.complete(jqXHR, textStatus); } } }, ajaxOptions)); } // usage $.ajaxLoadingWrapper('#button-ajax-start-selector', '#loading-message-selector', { url: myUrl, success: function(data){ // myAjaxSuccess(data); }, });
URL: ajax-loading-wrapper
Comments
