Decrease number of ajax requests
I have some checkboxes that act as search filters. These search filters trigger an ajax request and data is sent back from the server and displayed to the user. The problem is, there are several of these checkboxes and the user can select one after the other, selecting say, three in a row which equals 3 ajax requests. Ideally i would like only one ajax request be performed if the user has selected more than one search filter.
I'm trying to brainstorm and get some input on how i can wait for the user to finish checking the checkboxes before performing the ajax request. I've thought of alternatives such as adding a search button but it would be nice for the user to just select the options they want and be displayed the results.
I'm using jQuery, but mainly i'm just after ideas on how to implement this.
When the first checkbox is checked, set a setTimeout timer to a function to get search results. If another checkbox is set, reset the timer. If the user waits long enough for the setTimeout to fire, perform the search. That way you get the best of both worlds, fewer calls but automatic searching.