.load()成功函数 [英] .load() with success function

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

问题描述

我知道这已经被问了很多遍了...

I know this has been asked many times before...

我有一个简单的(#DIV')的负载。(为file.php ID ='+ ID +'和;页面='+页)

在上单击事件的行为如下:

The on click event acts as follows

function recp(id) {  
  var user = $('#page').attr('page'); 
  $("#button").hide()
  $("#loading").html('<img src="images/loader.gif">');
  $('#div').load('file.php?id='+id+'&page='+page); 
  $("#loading").empty();
  $("#button1").show()
}

我有我的网站上使用Ajax后一个类似的过程,作品非常漂亮,但我似乎无法得到这与工作.load()

将需要一点忠告。干杯。

Would need a bit of advice. Cheers.

推荐答案

问题是,负荷是异步的。该函数调用返回的的AJAX请求完成。如果你有需要执行后,请求完成code,你需要使用的的完整回调:// api.jquery.com/load/">API

The problem is that load is asynchronous. The function call returns before the AJAX request is complete. If you have code that needs to be executed after the request is complete, you need to use the complete callback specified in the API:

$('#div').load('file.php?id='+id+'&page='+page, function(){
    $("#loading").empty();
    $("#button1").show();
}

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

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