articles.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. $('#sidebar').stickySidebar({
  2. topSpacing: 20,
  3. bottomSpacing: 20,
  4. });
  5. (function ($) {
  6. "use strict";
  7. let counter;
  8. counter = 10;
  9. let loading = true
  10. $(window).scroll(function () {
  11. if ($(window).scrollTop() + $(window).height() == $(document).height()) {
  12. function see_more() {
  13. if (loading) {
  14. var csrftoken = $.cookie('csrftoken')
  15. let info;
  16. info = {
  17. 'counter': counter,
  18. 'csrfmiddlewaretoken': csrftoken,
  19. 'flag': 'articles',
  20. 'tag': tag,
  21. 'column': column,
  22. 'search': search,
  23. 'order': order
  24. }
  25. $.ajax({
  26. type: "POST",
  27. url: '../article_list_call/',
  28. data: info,
  29. datatype: 'json',
  30. headers: {"X-CSRFToken": csrftoken},
  31. success: function (data) {
  32. counter = counter + 10;
  33. if (data.indexOf('已经到底了') === -1) {
  34. $("#articles_list").append(data);
  35. } else {
  36. loading = false;
  37. }
  38. }
  39. })
  40. }
  41. }
  42. see_more();
  43. }
  44. })
  45. })(jQuery);