Aggregating / Collecting AJAX requests
Posted
by Ganesh Shankar
on Stack Overflow
See other posts from Stack Overflow
or by Ganesh Shankar
Published on 2010-03-20T12:37:39Z
Indexed on
2010/03/20
12:41 UTC
Read the original article
Hit count: 370
I have situation where a user can manipulate a large set of data (presented in a table) by using a bunch of filters represented as checkboxes.
The page is AJAXed up so the user doesn't have to wait for a full page refresh every time they click a filter. The way it's currently implemented is by having an event handler watch all the checkboxes and request filtered data from the server when a click event is triggered.
This works fine. However, there is a usability & performance issue with doing it this way. For example, if a user clicks 6 checkboxes, 6 AJAX requests are triggered and they all come back at various intervals causing the page to be updated 6 times. This will most probably annoy the user and seems rather inefficient.
I want to put some kind of timeout on the event handler to do something like this: "Wait for 1 second and if there are no more filters clicked trigger the AJAX request". However, at the moment I've only been able to delay all 6 requests by 1 second. I'm not sure how to aggregate / collect the filter info into 1 AJAX request.
Any suggestions would be greatly appreciated!
© Stack Overflow or respective owner