显示在ajax加载时加载特定div中的gif(display loading gif in specific a div while ajax loading)

系统教程 行业动态 更新时间:2024-06-14 17:01:34
显示在ajax加载时加载特定div中的gif(display loading gif in specific a div while ajax loading)

下面的代码是在ajax加载数据时显示加载gif。 下面的代码显示了浏览器整个页面的gif。 但我希望它只显示在div-Summary-Report上。 它能够做到吗?

<div class="row"> <div class="col-lg-12 div-Detailed-Report"> //some content </div> </div> <div class="row"> <div class="col-lg-12 div-Summary-Report"> //some content </div> </div> <style type="text/css"> .no-js #loader { display: none; } .js #loader { display: block; position: absolute; left: 100px; top: 0; } .se-pre-con { position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; z-index: 9999; background: url('../../Content/kendoui/Bootstrap/loading_2x.gif') center no-repeat #fff; } </style> <script> $(document).ready(function () { $(document).ajaxStart(function () { $(".se-pre-con").show(); }).ajaxStop(function () { $(".se-pre-con").hide(); }); }); //some ajax function </script>

below codes are to display loading gif while ajax is loading data. The codes below displaying the gif for the whole page of my browser. But I want it to display only at div-Summary-Report. Is it able to do this?

<div class="row"> <div class="col-lg-12 div-Detailed-Report"> //some content </div> </div> <div class="row"> <div class="col-lg-12 div-Summary-Report"> //some content </div> </div> <style type="text/css"> .no-js #loader { display: none; } .js #loader { display: block; position: absolute; left: 100px; top: 0; } .se-pre-con { position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; z-index: 9999; background: url('../../Content/kendoui/Bootstrap/loading_2x.gif') center no-repeat #fff; } </style> <script> $(document).ready(function () { $(document).ajaxStart(function () { $(".se-pre-con").show(); }).ajaxStop(function () { $(".se-pre-con").hide(); }); }); //some ajax function </script>

最满意答案

这将解决您的问题。 将div中的gif加载隐藏,当ajax开始显示gif时,ajax再次完成隐藏gif。

<div class="row"> <div class="col-lg-12 div-Summary-Report"> <img src="loading.gif" class="loading"> //some content </div> </div> <style type="text/css"> .loading{display:none;} </style>

This is would solve your problem. Place loading gif inside div hidden and when ajax starts show gif and when ajax complete hide gif again.

<div class="row"> <div class="col-lg-12 div-Summary-Report"> <img src="loading.gif" class="loading"> //some content </div> </div> <style type="text/css"> .loading{display:none;} </style>

更多推荐

display,gif,div-Summary-Report,电脑培训,计算机培训,IT培训"/> <meta name=&quo

本文发布于:2023-04-20 18:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/95ee23286203b72d5c3fdc332840fb21.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   div   ajax   gif   specific

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!