Suggest on Google - no ajax

    Honestly, I have long had the impression that if a client (in this case, a browser) must take something from the server without reloading the page, then it must be AJAX XMLHttpRequest. A user poked somewhere, an event triggered, an AJAX XMLHttpRequest request was generated , a response came from the server, the callback processed it, and the user saw something.

    But there is a problem. If the user quickly and often presses the keys, a number of parallel requests are created and as a result, a request sent later can work out much earlier than the earlier request, which will result in the output of incorrect data.



    Yes, you can get confused, figure out how to extinguish early requests or make queues. Or something else.

    I like Google's decision on this subject:

    image

    Ie each time you click on the button in the search field, the entered text is substituted in the URL of the connected JS file, on the server, depending on the entered file parameters, a JS array with data is generated and at the end the function of rendering results is called.

    No AJAX XMLHttpRequest requests, everything is simple and quick.

    Also popular now: