I use the built-in ajax function for MVC2. Basically, the user enters a search query, and each press of a key displays a set of results for the query. This works in almost all cases, but sometimes the server is a bit slow with one answer, and thus, the result for the next keystroke returns to the previous one. When the previous result of the key result set is finally returned to the client, it will overwrite the results for a newer search query that should really be shown.
My code more or less matches the following lines:
<% using (Ajax.BeginForm("SearchUser", null,
new AjaxOptions()
{ UpdateTargetId = "findUserResults" },
new { id = "findUserAjaxForm" })) {%>
Each keystroke passes this form and thus displays the results in the findUserResults element.
How can I prevent old results from showing when using the built-in functions introduced in MVC2?
source
share