Prevent the page from being displayed only when all the elements of the page are loaded

0

I have a page in html, in that ready data, this part looks like this:

        <table class="table table-responsive">
            <thead>
                <tr>
                    <th>Item 1</th>
                    <th>item 2</th>
                    <th>item 3</th>
                    <th>item 4</th>
                </tr>
            </thead>

            <tbody>
                {% for item in itens %}
                <tr>
                    <td><a href=""><img src="{{ item.att1 }}" width="50px" /></a></td>
                    <td><a href=""><strong>{{ item.att2 }}</strong></a></td>
                    <td><strong>{{ item.att3 }}</strong></td>
                    <td><strong style="color: green">{{ item.att4 }}</strong></td>
                </tr>
                {% endfor %}
            </tbody>
        </table>

I'm using Django in my application.

The problem is this: the data being listed is captured on the backend and comes from an external server, which often delays loading of the page.

What I wanted to do was load the whole page (except the table), and meanwhile I could put any message to the user. And only then when all items were loaded, would the table be displayed.

I've been researching but I have not found anything related. Could someone help me?

    
asked by anonymous 29.10.2016 / 06:55

1 answer

1

So Naldson, for you to do this the solution is you load this table with an asynchronous call via JavaScript, that is, when the page is loaded your JavaScript makes an Ajax request to the server, yours or external, this goes from your architecture, and when you get that response from the server you mount the table by adding the rows and columns of it with JavaScript as well.

29.10.2016 / 12:11