Denis Luis Espinosa Perez Denis Luis Espinosa Perez - 8 months ago 48
HTML Question

Wait page in search in symfony2?

I'm doing a search engine and I want to make a waiting page while searching, as do the sites of the airlines while looking for availabilities? Any ideas
I'm using Symfony2

Answer Source

Your question is imprecise but I think you can arrange it as follows:

  1. Prepare search form that you include in any place on your web
  2. Prepare search method and separate routing to this method in symphony. This method should return JSON result.

To take over control under the request and response after somebody uses search form you need to take over submit event and change it to AJAX request. You can do it for example this way (using JQuery):

        $('body').on('submit', '#search_form', function (e) {

                type: 'POST',
                url: searchservice_url_here,
                data: serialized_entry_data_here
            .done(function (data)
            .fail(function (jqXHR, textStatus, errorThrown)
                    '<div class="alert alert-danger fade in">'
                    + errorThrown
                    + '</div>'


  1. loaderSwitch is a javascript function which shows or hides any "wait for results" animation.
  2. searchservice_url_here - is URL to your search method
  3. serialized_entry_data_here - is JSON with data you want to post to search method
  4. renderResults is a javascript function you need to prepare to render results.
  5. result_place is id of div, where you want to print search results

Alternatively you can response with HTML and simply paste it in the #result_place

I hope this will help.