S
S
Std1372020-05-07 07:20:11
JavaScript
Std137, 2020-05-07 07:20:11

What is the variable loadingbar responsible for in this code?

In one of the articles such code is given. Simulates loading content when scrolling the page. In principle, everything is clear. Explain the purpose of the #loadingbar variable whose display property is being changed?

var loading = false;
$(window).scroll(function(){
  if((($(window).scrollTop()+$(window).height())+250)>=$(document).height()){
    if(loading == false){
      loading = true;
      $('#loadingbar').css("display","block");
      $.get("load.php?start="+$('#loaded_max').val(), function(loaded){
        $('body').append(loaded);
        $('#loaded_max').val(parseInt($('#loaded_max').val())+50);
        $('#loadingbar').css("display","none");
        loading = false;
      });
    }
  }
});

$(document).ready(function() {
  $('#loaded_max').val(50);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexBergal, 2020-05-07
@AlexBergal

#loadingbar is not a variable, it's an element on the page that actually displays the loading progress.
- scrolled
- the bar was displayed
- loading of data began
- upon completion, the bar was hidden

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question