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.
精彩评论