Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Continuous server query in client using JQuery

 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I just want to know if this is possible in JQuery. I have a graph (statistical) in my page, and this graph gets updated automatically by ajax depending if there are changes in the data model. Now to do this, I have to read some data from the server continuously, say every minute, and change my display accordingly. The data read from the server is basically a flag; if changes have been made to the data model, this means that I have to update my display.

Is this possible in JQuery? Is there a way to continuously read data from the server, and I can assign the number of seconds or minutes that will be executed? Some examples will be greatly appreciated.

Thanks in advance,

Eugene
[ November 28, 2008: Message edited by: Eugene Abarquez ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think setTimeout would be your friend. When the response comes back, you use setTimeout and make it do another call to the server.

I do not recommend using setInterval in this case.


Eric
 
Eugene Abarquez
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:
I think setTimeout would be your friend. When the response comes back, you use setTimeout and make it do another call to the server.

I do not recommend using setInterval in this case.


Eric




Hi Eric,

Thanks for the reply.

As I understand it, window.setInterval() will make a call every x number of seconds, while window.setTimeout() will make a call only once, after x seconds. Basing from what I need, window.setInterval() seems to be the more obvious choice. I am interested to know why you are recommending the use of window.setTimeout() instead of window.setInterval(), and just call it every time the response comes back.

Thanks in advance,

Eugene
 
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I often use setInterval(). Eric, what's behind your admonition?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!