


Use jquery to implement scrolling browser scroll bar loading data in asp.net website development (similar to Tencent Weibo)_jquery
I have basically been using Tencent Weibo since it was launched. Until now, as a developer, I have also seen that Tencent Weibo has been constantly changing. I don’t know if you have noticed that Tencent Weibo provides two There are two ways to load data: one is paging, and the other is scrolling the browser scroll bar to load data. I think everyone has done too much of the paging function. Today I will share with you how I use the scroll bar to load data
below Start the lecture:
Let me talk about the idea first. I use Jquery, and then use Jquery’s ajax() method to load remote data through HTTP requests. When using Jquery, you must first apply the jquery.min.js class library. If If it is not available locally, you can also directly quote the following address.
Okay, let’s take a look at the core code:
// - -!, you know.
var count=<%=allcount %>;
var times=0;
var loaded = true;
function Add_Data()
{
var top = $("#main_left_add").offset().top;
if(loaded && ($(window).scrollTop() $(window).height() > top ))
{
$("#main_left_add").html("Data loading...");
times ;
$.ajax(
{
type: "POST",
dataType: "text",
url: "weibo.ashx",
data: "userid=" <%=hf.Value %> "&touserid=" <% =hf1.Value %> "&count=" count "×=" times "&type=1",
success: function(data)
{
//alert("Append " times " times Data.");
if(data == "No data")
{
$("#main_left_add").css("display","none");
loaded=false ;
AddEffect();
}
else if(data == "")
{
$("#main_left_add").html("Click to load more..." );
$("#main_left_add").css("display","block");
loaded=false;
AddEffect();
}
else if(data ! = "")
{
$("#main_left_down").append(data);
AddEffect();
}
}
}
);
}
}
$(window).scroll(Add_Data);
//Click to add data
$("#main_left_add").click(function(){
$.ajax ({
type: "POST",
dataType: "text",
url: "weibo.ashx",
data:"userid=" <%=hf.Value %> "&touserid=" <%=hf1.Value %> "&count=" count "×=" times "&type=2",
success: function(data){
if(data=="No data")
{
$("#main_left_add").css("display","none");
AddEffect();
}
else
{
$("#main_left_down").append(data);
$("#main_left_add").html("Click to load more...");
AddEffect();
}
}
});
//Mouse movement effect
$("#main_left_add").mouseover(function(){
$(this).css("background-color", "#e4eef8");
});
$("#main_left_add").mouseout(function(){
$(this).css("background-color","#f0f5f8") ;
});
This is the front-end js code. Let me explain the code a little bit: count is the total number of data defined. Two divs are defined. One div is used to append data. A div is used to determine the position of the scroll bar, and a *.ashx file is created to process the program and return the corresponding data. Based on this data, we must determine the loading situation. After the scroll append is completed, I also added an additional "Click to load more" Function...", the implementation of this function is similar to the above...the codes are all above for your reference.
Note: In order to prevent the scroll event from being executed all the time, a loaded is defined to control the execution of the scroll event.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The method of customizing resize symbols in CSS is unified with background colors. In daily development, we often encounter situations where we need to customize user interface details, such as adjusting...

Using locally installed font files in web pages Recently, I downloaded a free font from the internet and successfully installed it into my system. Now...

Discussion on using custom stylesheets in Safari Today we will discuss a custom stylesheet application problem for Safari browser. Front-end novice...

How to use locally installed font files on web pages Have you encountered this situation in web page development: you have installed a font on your computer...

Why do negative margins not take effect in some cases? During programming, negative margins in CSS (negative...

How to use JavaScript or CSS to control the top and end of the page in the browser's printing settings. In the browser's printing settings, there is an option to control whether the display is...

The problem of container opening due to excessive omission of text under Flex layout and solutions are used...

Implementing responsive layouts using CSS When we want to implement layout changes under different screen sizes in web design, CSS...
