jquery fadeout, load, fadein

后端 未结 4 1550
無奈伤痛
無奈伤痛 2020-12-16 16:59

I am using JQuery and what I want to happen is.

Div fades out using the fadeOut command. It then loads content from a url using the load command. Then once content

相关标签:
4条回答
  • 2020-12-16 17:11

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

    $("#myDiv").fadeOut().load('www.someurl.com', function() {
      $(this).fadeIn();
    });
    
    0 讨论(0)
  • 2020-12-16 17:23

    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();
        }
    });
    
    0 讨论(0)
  • 2020-12-16 17:26
    $("#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

    0 讨论(0)
  • 2020-12-16 17:28

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

    0 讨论(0)
提交回复
热议问题