This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages 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

how to avoid multuple ajax calls

 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i have a group of checkboxes. On click of each checkbox, an ajax call is made and results are displayed. This works when the user selects the check box slowly.However, when the user selects checkbox quickly, then multiple ajax calls happens at same time and gives inconsistent results. How can i prevent this, to ensure that second ajax calls happens only after first completes.

I am making the ajax call something like

 
Sheriff
Posts: 67619
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
As you are already using jQuery there are a number of ways it could help you, depending upon how you want to handle the situation.

If you want to cancel any existing Ajax requests when a new one is fired, you can use a global Ajax start event to cancel any outstanding requests.

If you want to queue them up for serial execution, look into function queues. (Which, if you have a copy of jQuery in Action, are covered near the end of chapter 5).

Or do you just want to not initiate new requests if there are any unfinished ones?

It all depends on how exactly you want to handle the situation.
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to queue them up for serial execution. so let me go through the chapter 5....Will get back to you if have any doubts :-)

thanks!
 
reply
    Bookmark Topic Watch Topic
  • New Topic