SHARE
TWEET

Untitled

a guest Oct 10th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function() {
  2.  
  3.     $('.load-more').on('click', function(){
  4.         const btn = $(this);
  5.         const loader = btn.find('span');
  6.  
  7.         $.ajax({
  8.             url: './src/data.html',
  9.             type: 'GET',
  10.  
  11.             beforeSend: function() {
  12.                 btn.attr('disabled', true);
  13.                 loader.addClass('d-inline-block');
  14.             },
  15.  
  16.             success: function(response) {
  17.                 setTimeout(function() {
  18.                     loader.removeClass('d-inline-block');
  19.                     btn.attr('disabled', false);
  20.                     $('.after-posts').before(response);
  21.                 }, 2000);
  22.             },
  23.  
  24.             error: function() {
  25.                 alert('Error!');
  26.                 loader.removeClass('d-inline-block');
  27.                 btn.attr('disabled', false);
  28.             }
  29.  
  30.         }); //ajax
  31.  
  32.     });
  33. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top