Posted By

graceman9 on 09/18/11


Tagged

wrapper ajax loading progress


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

jillella
spee66


jQuery ajax loading wrapper (realy simple :))


 / Published in: jQuery
 

URL: ajax-loading-wrapper

And how you do this?

  1. // wrapper function
  2. jQuery.ajaxLoadingWrapper = function(load, loading, ajaxOptions) {
  3. $.ajax($.extend({
  4. beforeSend: function(jqXHR, settings){
  5. $(load).hide();
  6. $(loading).show();
  7. if (ajaxOptions.beforeSend) {
  8. ajaxOptions.beforeSend(jqXHR, settings);
  9. }
  10. },
  11. complete: function(jqXHR, textStatus){
  12. $(loading).hide();
  13. $(load).show();
  14. if (ajaxOptions.complete) {
  15. ajaxOptions.complete(jqXHR, textStatus);
  16. }
  17. }
  18. }, ajaxOptions));
  19. }
  20.  
  21. // usage
  22. $.ajaxLoadingWrapper('#button-ajax-start-selector', '#loading-message-selector', {
  23. url: myUrl,
  24. success: function(data){
  25. // myAjaxSuccess(data);
  26. },
  27. });

Report this snippet  

You need to login to post a comment.