开发者

Check if file has been loaded using .load()

开发者 https://www.devze.com 2023-03-15 04:27 出处:网络
How would I check if file has been loaded in a div, and if not, try again (reload 开发者_JAVA技巧it)

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

精彩评论

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