【发布时间】:2013-05-13 00:17:28
【问题描述】:
我需要暂停 .each 循环,让 iframe 有时间加载。有没有办法做到这一点?我研究了回调等等,但没有运气。我不想超时,因为我需要确保 iframe src 完全加载。
$.ajax({
type:'post',
traditional: true,
url: '/Reportedit/exportPdfCharts',
dataType: 'json',
cache: 'false',
contentType: 'application/json; charset=utf-8',
success: function(data) {
$.each(data, function() {
var url = "/Reportedit/createonechart";
$("#iframe-chart").attr("src", url);
//NEED TO PAUSE HERE UNTIL iframe source has completely loaded.
});
}
});
【问题讨论】:
-
您可以在 iframe 上连接 onload 事件,但由于 ajax 调用是异步的,因此您不能在通话中暂停。如果您需要等待,那么 AJAX 可能不是正确使用的工具。
-
你不能暂停 $.each 循环。
标签: jquery ajax iframe load each