Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  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. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement