Symfony 3.2 – Loading state till the page fully loaded

问题内容:

Hello everyone,

I’m stuck at some javascript / symfony issue. I got a page that takes more than 10 secondes to load (a lot of forms in it).

The problem is that when the page shows up, it is only the html that works and when users start playing with the forms, its not working (cause its stacks ajax requests and return nothing).

here an example set of ajax reponses for this page

So I handled a part of it by setting a loading state for each submit. (I used gasparesganga loading library ).

$(document).ajaxStart(function(){
        $.LoadingOverlay("show");
    });
    $(document).ajaxStop(function(){
        $.LoadingOverlay("hide");
    });

Everything works good when the page is fully loaded.

But the problem persists between the landing on the page and the time it fully load.
I tried to display a spinner when the user get on the page :

$.LoadingOverlay("show");
window.onload = function() {
        console.log('window loaded');
        $.LoadingOverlay("hide");
    };    

Or try to replace the at the beginning of my code:

<script>
    $("body").LoadingOverlay("show");
</script>

But none of this works; thus when I land on the page, I see first the HTML for 8 seconds and then it shows the spinner.

So my question concerns the fact that Symfony have a role in this : the controller do his calculations and it displays the view as it is till it gets the full informations — and next load the JS.
If someone could give me some hint, it would be great !

Thanks for the reading and for your help.

Youyou

问题评论:

原文地址:

https://stackoverflow.com/questions/47756570/symfony-3-2-loading-state-till-the-page-fully-loaded

添加评论