473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

(Scroll Bar + Ajax)Problem

Basic Problem is Every scroll of scrollbar makes an ajax call.So if user play with scrollbar say 100 times 100 ajax calls go and server starts processing 100 calls.So abort won't help.The last time the scroll bar has stopped scrolling(say for 1000 millisecond),ajax call should go.My function uses object function call.So how can i use setTimeOut()

My function looks likes this

temp contain xmlHTpp object
Expand|Select|Wrap|Line Numbers
  1. var temp=new xmlHttpObject();
  2.  
  3. div.onscroll={temp.makeAjaxCall()};
  4.  
here temp.makeAjaxCall should not be called until scrolling is stopped alteast for 1000 millisecond
Nov 14 '07 #1
5 2315
Dasty
101 Expert 100+
I would like to know answer too. But I would make it that way:

[HTML]<script language="javascript">
var timeoutID = null;

function ajax_function()
{
timeoutID=null;
alert('i am in ajax function');
}
</script>
[/HTML]

and set onscrollevent this way:

[HTML]<div onscroll="if (timeoutID){clearTimeout(timeoutID)}; timeoutID=setTimeout(ajax_function,1000);">[/HTML]

But I am not sure how "hard" it is for browser to start/terminate timeouts (because browser will process onscrollevent many times). Test it and let me know .. If someone else know "cleaner" solution, I would like to hear it too.
Nov 14 '07 #2
:( i want object passed to setTimeOut
Nov 22 '07 #3
acoder
16,027 Expert Mod 8TB
Here is something I've not tested, but worth a try:

Use the Date object. Whenever a scroll action takes place, update a variable with the time in milliseconds.

At the same time, a setInterval is continuously running a function every 500 milliseconds. It checks this variable to see if 1000 milliseconds have passed. If not, nothing happens. If they have passed, make the Ajax request.
Nov 22 '07 #4
Here is something I've not tested, but worth a try:

Use the Date object. Whenever a scroll action takes place, update a variable with the time in milliseconds.

At the same time, a setInterval is continuously running a function every 500 milliseconds. It checks this variable to see if 1000 milliseconds have passed. If not, nothing happens. If they have passed, make the Ajax request.
Thnx acoder

BUT
The problem is that the function that is to be called from setInterval is object funtion call :(. That is it go be like this

setInterval(object.function(),100);
but setInterval takes only string to be passed as function call
Any Help
Nov 27 '07 #5
acoder
16,027 Expert Mod 8TB
No, that's not the case. See, for example, this link.
Nov 27 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: idriss | last post by:
i want to scroll one frame's or canvas 's whole content (it will contain other subframes and subframes will contain bitmaps) I couldn't find where is my fault. if you can find my fault or have some...
1
by: Brian | last post by:
I've used the syncfusion method to autosize my datagrid row heights. The problem I run into is the vertical scrollbar does not take into account the new row heights. When I scroll to the bottom I...
3
by: Roy Harbert | last post by:
How do I get the editor to scroll with the mouse wheel????
1
by: Code Monkey | last post by:
using VS2005 and c# to create a windows forms application. One of my forms has a panel which I've added various controls to. Now, I've set the autoscroll property to true, which is great, but I...
12
by: Joel Byrd | last post by:
I am making an AJAX call when any one of a number of inputs in a form (search criteria) are clicked, checked, changed, etc. When the user clicks, checks, whatever, I am trying to display a...
1
by: monudjn | last post by:
Hi I am implementing ajax in portal. Using ajax i am able to updating the content of portlets asynchronously. However i am facing a problem The Problem: While submitting the form i am getting...
1
by: violinandviola | last post by:
I have just put 4 different ajax bits on this page: http://jimpix.co.uk/default-ajax.asp The ajax spits out chunks of images / news content, and users can view the chunks via next / prev links....
4
by: sheldonlg | last post by:
I haven't received an answer with my other post, so I am rephrasing it here. In php I have a 2D array which I "print". The headers force it to be a file on the user's system. The user receives...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.