开发者

Check if file has been loaded using .load()

How would I check if file has been loaded in a div, and if not, try again (reload 开发者_JAVA技巧it)

I'm using .load() and fancybox to load the file in.

  $('a.button-1').click(function(){

       $('#data').load('form1.html');

});

 $('a.button-2').click(function(){

       $('#data').load('form2.html');

});   


You can do something like what is in the jquery docs for load:

$("div").load("/test.html", function(response, status, xhr) {
  if (status == "error") {
    var msg = "Sorry but there was an error: ";
    $(this).html(msg + xhr.status + " " + xhr.statusText);
  }
});

http://jsfiddle.net/fqMWL/

Although I would be careful with just continuously retrying.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜