gpt4 book ai didi

javascript - 如何检查是否从 jQuery 调用了特定的 id?

转载 作者:数据小太阳 更新时间:2023-10-29 05:35:53 25 4
gpt4 key购买 nike

我有一个 MainContent div,其中包含可以从 ajax 加载的网站的主要内容。

我如何知道是否调用了 $("#MainContent").load("someUrl"),以便我能够将新的历史状态推送到网络浏览器?

最佳答案

就像 LSletty 所说,如果您想知道它何时被调用,请使用 .load() 本身的处理程序:

$("#MainContent").load("path/content.html", function(){
// Do stuff when load is called ...
});

更多信息在这里:jQuery load event

要在完成后采取行动,我会使用 .done() 处理程序。

按以下方式使用:

$("#MainContent").load("path/content.html").done(function(){
// Do stuff when load is done ...
});

来自 jQuery 文档:

Add handlers to be called when the Deferred object is resolved.

更多信息在这里:deferred.done() jQuery

关于javascript - 如何检查是否从 jQuery 调用了特定的 id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29714898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com