I have a search form with inputs and choices, and when some input / selection is changed, I run some js and then create an ajax request with jquery. I want the user not to make further changes to the form during the execution of the request, since at the moment they can initiate several remote searches at the same time, which actually causes a race between different searches.
It seems like the best solution is to prevent the user from interacting with the form while waiting for the request. At the moment, I am doing this in the most severe way, hiding the form before making an ajax request, and then showing it again about success / error. This solves the problem, but it looks awful and not very acceptable. Is there another, better way to prevent interaction with the form? To make things more complex, to allow beautiful choices, the user actually interacts with the gaps that js are connected to them to relate to the actual, hidden choices. Thus, although the gaps are not inputs, they are contained in the form and are real interactive form elements.
Grateful for any advice - max. Here is what I am doing now:
function submitQuestionSearchForm(){ //bunch of irrelevant stuff var questionSearchForm = jQuery("#searchForm"); questionSearchForm.addClass("searching"); jQuery.ajax({ async: true, data: jQuery.param(questionSearchForm.serializeArray()), dataType: 'script', type: 'get', url: "/questions", success: function(msg){ //more irrelevant stuff questionSearchForm.removeClass("searching"); }, error: function(msg){ questionSearchForm.removeClass("searching"); } }); return true; }
where the search class now only has {display: none}
source share