Skip to content Skip to sidebar Skip to footer

How To Show Progress Bar While Loading Page In Div Using Jquery

I am loading another page in one div using jQuery.Load('#divid','pageURL'); I have anchor tag on that anchor tag click I am calling jQuery.load('#divid','pageURL'); function this f

Solution 1:

jQuery( "#productName1" ).load(el, function() {
   //loaded
   jQuery("#productName1").addClass("loaded");
});

with in your css something like this:

#productName1 {
   background-image: url('images/loading.gif');
   background-position: center center;
}

#productName1.loaded {
   background-image: none;
}

Solution 2:

add a script to simulate loading before the call and when the call is finished, remove.

example:

function loadReview(el) {
    // add a gif loading in a div loaderjQuery("div.loadingDiv").html('<img src="link gif loading" />');
    jQuery("div.loadingDiv").show();
    jQuery("#productName1").load(el, function() {
        jQuery("div.loadingDiv").hide();
    });

    return false;
}

html:

<divclass="loadingDiv"style="display:none"></div><aonclick='loadReview(\"" + strexternalURL + "\");'href='#productName1'></a>

Solution 3:

Use success method

functionloadReview(el) {
    $("div.loaderDiv").html('<img src="imglink" />');
    $("div.loaderDiv").show();

    $("#productName1").load(el);

    returnfalse;

    success: $("div.loaderDiv").hide();
}

Post a Comment for "How To Show Progress Bar While Loading Page In Div Using Jquery"