1

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 function takes time to load page in that div, so I want to show loading image and changing the cursor style.

Below is the code snippet which I am using currently. in script.js file I have written function like that

function loadReview(el) {

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

    return false;
}

and I have anchor tag inside .aspx page like that.

<a onclick='loadReview(\"" + strexternalURL + "\");' href='#productName1'></a>
4

3 回答 3

0

在调用之前添加一个脚本来模拟加载,调用完成后,删除。

例子:

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

    return false;
}

html:

<div class="loadingDiv" style="display:none"></div>
<a onclick='loadReview(\"" + strexternalURL + "\");' href='#productName1'></a>
于 2013-11-06T10:13:19.870 回答
0
jQuery( "#productName1" ).load(el, function() {
   //loaded
   jQuery("#productName1").addClass("loaded");
});

在你的CSS中是这样的:

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

#productName1.loaded {
   background-image: none;
}
于 2013-11-06T10:11:41.010 回答
0

使用成功方法

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

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

    return false;

    success: $("div.loaderDiv").hide();
}
于 2013-11-06T10:15:19.553 回答