JQuery - Wait for two iframes to load

后端 未结 3 624
渐次进展
渐次进展 2020-12-21 23:14

I have a button that loads two different pages in two iframes. I need to wait for those loads to complete (like ready(), don\'t care about images and other content) and the

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-22 00:07

    Using $.when() will help you (jQuery 1.5 and higher). For example:

    function doAjax(){
       return $.get('foo.htm');
    }
    
    function doMoreAjax(){
       return $.get('bar.htm');
    }
    
    $.when( doAjax(), doMoreAjax() )
       .then(function(){
          console.log( 'I fire once BOTH ajax requests have completed!' );
       })
       .fail(function(){
          console.log( 'I fire if one or more requests failed.' );
       });
    

提交回复
热议问题