如何检查文件是否已加载到 div 中,如果没有,请重试(重新加载)
我正在使用 .load() 和 fancybox 来加载文件。
$('a.button-1').click(function(){
$('#data').load('form1.html');
});
$('a.button-2').click(function(){
$('#data').load('form2.html');
});
最佳答案
您可以执行类似于 jquery 文档中的 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);
}
});
尽管我会小心地不断重试。
关于jquery - 使用 .load() 检查文件是否已加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6443906/