简体   繁体   中英

Execute code after page has finished loading javascript / jquery

so I'm loading a url which takes a fairly long time to load, about a minute. I'm wondering how I should go about executing some additional javascript or jquery code only once the page has fully finished loading.

I was trying this but it was not working

$(document).ready(function()
{
    $.ajaxSetup(
    {
        cache: false,
        success: function() {
            $('#div_loading').hide();
            $('#div_done').show();
        }
    });
    $.ajax("process.php?q=<?=$id?>&bitrate=<?=$bitrate?>");
});

You could use a jQuery deferred object eg

$.ajax("process.php?q=<?=$id?>&bitrate=<?=$bitrate?>").then(function(data){

});

Basically when the $.ajax call returns, the then function will be executed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM