Can an Ajax call end before loading the DOM?

I collect data through a jQuery Ajax call and output it to the page. I need to wait for the DOM to load and the Ajax call to complete before I can use the data to display it on the page. Can an Ajax call ever end before loading the DOM? I'm just trying to determine where I need to put my method, which will control the DOM and use the data that I return.

+3
source share
2 answers

I would wait for the DOM to load before calling AJAX. Although it is unlikely that DOM READY will take longer than calling AJAX, this is just good practice.

+2

AJAX , . script , , .

<div id="loadFile"></div>
<script>
    $("#loadFile").load('filename');
</script>

, , . AJAX DOM, AJAX? , .

0

Source: https://habr.com/ru/post/1744963/


All Articles