jquery fadeout, load, fadein

牧云@^-^@ 提交于 2019-11-29 03:47:32

you can use the load() callback function like this:

$("#myDiv").fadeOut().load("www.someurl.com", function(response, status, xhr) {
    $(this).fadeIn();
});

you might want to use the status of the load() call to see if everything was completed properly.

$("#myDiv").fadeOut().load("www.someurl.com", function(response, status, xhr) {
    if (status == "error") {
        // handle error
    }
    else
    {
        $(this).fadeIn();
    }
});
$("#myDiv").fadeOut(1000, function () {
    $("#myDiv").load("www.someurl.com", {limit: 25}, function(){
        $("#myDiv").fadeIn();
    });
});

The limit specifies how long time to wait for an answer in the load call

Use the success callback for .load(), like this:

$("#myDiv").fadeOut().load('www.someurl.com', function() {
  $(this).fadeIn();
});

you need to do the fading in the load callback function due to the asynchronous nature of AJAX.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!