Search code examples
javascriptjqueryajaxpageloadpage-loading-message

Synchronous AJAX, page loading gif


I have multiples Synchronous AJAX requests and it takes 3 seconds to load my page .

What i want to do is to display a loading page ( with a gif ) and when the page is loaded like when the Ajax requests are completed it fades out.

I followed an example from smallenvelop.com but the gif image looks freezed and just until the end that it displays the animation . how can i overcome this ? like even if the synchronous ajax requests are running my page can display the animation ?


Solution

  • When running a synchronous ajax request, the thread of the browser tab is doing just that: handling the request. That's the point of a synchronous request. It's also why the animation is frozen until the ajax request is finished.

    Use asynchronous ajax requests.