JQuery的.load()回调函数 [英] JQuery .load() callback function

查看:201
本文介绍了JQuery的.load()回调函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过很多的问题和解决方案,像这样的问题,但一切都没有为我工作。我有这样的:

 函数(){
    $(#BDIV)。负载(bosses.php#icc10n,函数(){
        返回$(#BDIV)的HTML()。
    });
}
 

但它不工作。为了澄清,我想内容加载到 #bdiv 然后返回 #bdiv 的内容。但似乎 $(#BDIV)。HTML()即使我把它放在一个回调函数的内容加载之前被返回。

解决方案

  $(#BDIV)。负载(bosses.php#icc10n功能(数据){
    //使用的数据参数
    // 例如。 $(数据).find('#icc10n')
});
 

I've seen lots of questions and solutions to problems like this but nothing has worked for me. I have this:

function() {
    $("#bdiv").load("bosses.php #icc10n",function(){
        return $("#bdiv").html();
    });
}

But it's not working. To clarify, I want to load content into #bdiv and then return the contents of #bdiv. But it seems that $("#bdiv").html() is being returned before the content is loaded even though I've put it in a callback function.

解决方案

$("#bdiv").load("bosses.php #icc10n",function(data){
    // use the data param
    // e.g. $(data).find('#icc10n')
});

这篇关于JQuery的.load()回调函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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