Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Continuous server query in client using JQuery

 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67620
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I often use setInterval(). Eric, what's behind your admonition?
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic