可一个Ajax调用完成后,DOM加载之前? [英] Can an Ajax call complete before the DOM is loaded?

查看:153
本文介绍了可一个Ajax调用完成后,DOM加载之前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过jQuery的Ajax调用抓取数据,并在页面上显示出来。我需要等待两个DOM加载和Ajax调用完成之前,我可以利用这些数据来在页面上显示出来。可一个Ajax调用完成过在DOM加载之前?我只是想确定我需要把我的方法是将操作DOM并使用我取回数据。

I am grabbing data through a jQuery Ajax call, and displaying it on the page. I need to wait for both the DOM to load and for the Ajax call to complete before I can use the data to display it on the page. Can an Ajax call ever complete before the DOM has loaded? I'm just trying to determine where I need to put my method that will manipulate the DOM and use the data I'm getting back.

推荐答案

我会等到DOM使你的AJAX调用之前加载。虽然这是不太可能的DOM就绪将采取比AJAX调用更长的时间,这是一个好的做法。

I would wait until the DOM has loaded before making your AJAX call. While it is unlikely that the DOM READY will take longer than the AJAX call, it's just good practice.

这篇关于可一个Ajax调用完成后,DOM加载之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆