且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Jquery加载然后编辑加载的内容

更新时间:2023-10-31 13:00:28

使用callback参数进行加载并将代码放入回调。

Use the callback parameter for load and put your code in the callback.

$("#content-basket").load("/BasketPage.htm?time=" + now.getMilliseconds(),null,
    function() {
           ...do stuff here after #content-basket is finished loading...
});

在查看jQuery之后,确实看起来响应是在调用任何回调之前注入的,所以DOM应该更新。您是否有可能重新使用可能引用之前存在的DOM元素但被负载替换的jQuery对象?

After looking at jQuery, it sure seems like the response is injected before any callbacks are called so the DOM should be updated. Is it possible that you are are re-using jQuery objects that may reference DOM elements that were previously there, but were replaced by the load?