1

我必须在我的代码中的某些页面上隐藏 ajax 预加载器。我怎样才能做到这一点。你的建议会有所帮助。

代码是:

<script language="javascript" type="text/javascript">
    $(window).load(function() {
    //alert("Loader-->"+n[1])                                                                                                                                                                                                                                                                                     $('#loading').hide();
           if(n[1]!=undefined){
            /*jQuery('#loading').fadeOut(10, function() {
             jQuery('body').css('overflow','visible');
             jQuery(this).remove();
        });*/

        /*$('#loading').ajaxStop(function(){
                $(this).hide();
        });*/
        //$('#loading').hide();
        }
        //$('#loading').hide();
    });

在这个代码片段中,我也粘贴了我已经处理但没有工作的代码。

html代码

        <div align="center">

            <div align="center" id="container"> 
                <div id="logo" align="center" ><img src="images/Updated_1logo.png" border="0" alt="STIHL logo"/> </div>

                <div style="clear:both"></div>

                <div id='divMain'>
                    <table width="100%">
                        <tr>
                            <td width="50%" >&nbsp;</td>

                            <td style="position:absolute;left:60%;top: 50%;">
                                <img src="images/gray_image_002.png"  border="0" />
                            </td>
                        </tr>
                    </table>          

                    <div  id="circle1"> 
                        <div id="circle12"><br/> <br/><b>Employee Benefits</b></div> 
                    </div>

                    <div class="circle" id="circle2">
                        <div id="circle22"><br/> <b>Expectations</b></div>
                    </div>

                    <div class="circle" id="circle3">
                        <div id="circle32"><br/> <b>Manufacturing <br/>Operations Safety</b></div> 
                    </div> 
                </div>
</div>
</div>

不要使用结束标签

4

2 回答 2

2

您可以这样做,在某些页面上隐藏 ajax 预加载器,例如:

$(document).ready(function () {
    $(document).ajaxStart(function () {
        $('#loading').show();
    }).ajaxStop(function () {
        $('#loading').hide();
    });
});
于 2013-06-01T09:30:04.450 回答
0

这段代码运行良好 4 me

<script>
var js = '<html><div id="loading"><img id="loading-image" src="images/ajax-loader.gif" alt="Loading...  /></div></html>'
if (window.location.href.indexOf("divModule") != -1) {
    //alert('here'+window.location.href.indexOf("divModule"))
    $("body").prepend(js);
}               
</script>
于 2013-06-01T11:59:27.040 回答