【问题标题】:How to check whether the content in DIV has loaded?如何检查DIV中的内容是否已经加载?
【发布时间】:2013-04-16 17:04:37
【问题描述】:

DIV 中的内容是在同一页面上按下按钮后加载的。 该按钮向服务器发送请求,一个 python 文件,文件返回一些文本,这些文本使用 Ajax 在页面的div 部分加载。

我实际上希望在div 内容未加载之前一直存在“加载图像”。

<form id="f1">
    <textarea name="textcontent" id="styled" cols="40" rows="4"></textarea>
    <br>
    <input onclick='JavaScript:xmlhttpPost("/cgi-bin/test.py")' type="button" value="Show" class="blue"/>
    <br>
    <div id="qList"></div>
</form>

服务器返回的文本将被加载到id为“qList”的div中。

请帮忙!

【问题讨论】:

  • 我认为如果您使用来自 ajax 调用者 的回调来管理 on loading 情况会更好。我不知道对象JavaScript:xmlhttpPost 有哪些回调,但我确信它有一些可以管理这个。

标签: html ajax web-applications


【解决方案1】:
<div id="qList"><!-- insert loading image code here --></div>

当你的xmlhttpPost("/cgi-bin/test.py") 完成后,它可以用它想要的内容替换加载图像。

【讨论】:

    猜你喜欢
    • 2021-08-08
    • 1970-01-01
    • 2012-03-04
    • 1970-01-01
    • 1970-01-01
    • 2023-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多