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.

Answers


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.


Need Your Help

How can I embed a third-party web page using an embedded browser in a WinJS application?

windows windows-8 windows-runtime winjs

When developing Windows 8 apps with C# / XAML you can embed a third-party web page into an application using the WebView control.

How to clone a HttpPostedFile

c# asp.net symantec

I have an application that allows a user to upload a file, the file is scanned with Symantec protection engine before it is saved. The problem I'm encountering is that after the files are scanned ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.