troubleshooting Question

Loading divs during onscroll

Avatar of kmartin7
kmartin7Flag for United States of America asked on
JavaScriptJScriptAJAX
3 Comments2 Solutions1343 ViewsLast Modified:
I am trying to figure out a way to load divs with content using ajax (ie 6 & 7 only) when the user scrolls up or down. The idea is that the user will select an item from a point in a table of contents, and only that data will load (which works). But we are trying to make requests back to the server for more information if the user scrolls up or down. When a div comes into view, it will make a small request back to the server for the data to load. The issue we have is wireless bandwidth, and we don't want to load the entire page because the pages are quite large. Something like the following (ref id7); only fire an even whenever *each div* comes into the browser window:

<body>
<div style="height:150px;" id="id1">
id1
</div>
<div style="height:150px;" id="id2">
id2
</div>
<div style="height:150px;" id="id3">
id3
</div>
<div style="height:150px;" id="id4">
id4
</div>
<div style="height:150px;" id="id5">
id5
</div>
<div style="height:150px;" id="id6">
id6
</div>
<div style="height:150px;" id="id7" onscroll="fireEvent()">
id7
</div>
<div style="height:150px;" id="id8">
id8
</div>
<div style="height:150px;" id="id9">
id9
</div>
<div style="height:150px;" id="id10">
id10
</div>
<div style="height:150px;" id="id11">
id11
</div>
<div style="height:150px;" id="id12">
id12
</div>
<div style="height:150px;" id="id13">
id13
</div>
<div style="height:150px;" id="id14">
id14
</div>
<div style="height:150px;" id="id15">
id15
</div>
<div style="height:150px;" id="id">
id16
</div>
</body>

Any ideas are appreciated.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros