Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.92 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. loader for very large HTML content retrieved by jquery
  2. $("#offerForm").submit(function() {  
  3.     //show loader
  4.              $('#demo').append('<div id="zloader" style="background: #fff url('preloader2.gif') no-repeat scroll 10px center;
  5. padding-left: 40px;">Loading, please wait...</div>');
  6.  
  7.     //post the form
  8.          $.post('getoffers.php', $("#offerForm").serialize()
  9. + '&page=' + page, function(data) {
  10.  
  11.                        //show the returned data
  12.                $('#demo').html(data.htmlOutput);
  13.                    }
  14.     }
  15.        
  16. $.post('<url>', {<data>}, function (data) {
  17.     $('#demo').append(data.htmlOutput).find('#zloader').remove();
  18. });
  19.        
  20. $.ajax({
  21.     url: 'get-offers.php',
  22.     type: 'POST',
  23.     beforeSend: function () {
  24.         // append the loader
  25.     },
  26.     success: function( data ) {
  27.         // show the returned data
  28.     }
  29. });
  30.        
  31. $.ajax{
  32. ...
  33. success:function(){
  34.     // Show new content
  35.     // Hide loader
  36. }}