如何加载单独的事业部无负载整个页面,并显示加载状态? [英] How do I load Individual Div without load entire page and show loading status?

查看:119
本文介绍了如何加载单独的事业部无负载整个页面,并显示加载状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能单独加载单独的事业部,而不会影响该div PHP和MySQL或Ajax和SQL当前页面并显示加载状态

How can I load individual Div separately without affecting current page and show loading status for that div with PHP and MySQL or Ajax and SQL

推荐答案

我这样做:

首先你的隐藏分区的加载,如果它和负载按钮:

first you have the hidden div with a loading if in it and a load button:

<div id="displayDiv" style="display: none">
  <img id="loadingGif" src="loadingGif" style="display:none"; />
  <div id="actualContent" style="display:none" />
</div>
<input type="button" id="loadButton" />

然后你有JS code(使用jQuery)

Then you have the JS code ( I use jQuery )

<script type="text/javascript">
   $(document).ready( onDocumentReady); // this runs before page load

   function onDocumentReady()
   {
      $('#loadButton').click( onLoadClick ); //assign action on button click
   }   

   function onLoadClick()
   {
       $('#loadingGif').show(); // show the loading gif. It won't show as long as it's parent is hidden
       $('#actualContent').hide(); // hide the actual content of the response;
       $('#displayDiv').show(); // display the div
       $.get("test.php", onRequestComplete ); // make the ajax request to the stand alone PHP file
      //so as long as the content loads, the loading gif will show;
   }

   function onRequestComplete( data )
   {
      $('#loadingGif').hide();
      $('#actualContent').html( data );
      $('#actualContent').show();
   }
</script>

所以。你有一个容器displayDiv;里面你有一个形象loadingGIf和另一个容器actualContent;当您单击Load按钮,大容器装载GIF出现,通知的东西是加载用户。当内容被加载,你只是隐藏loadingGif,并显示在actualContentGIF的信息。在test.php的,你只是附和必​​须出现在股利。我推荐使用JSON,但你会阅读更多关于它。

So. You have a container "displayDiv"; inside you have an image "loadingGIf" and another container "actualContent"; When you click the load button, the big container with the loading gif appears, notifying the user that something is loading. When the content is loaded, you just hide the loadingGif, and display the info in the "actualContent" gif. In the test.php you just echo what must appear in the div. I recommend using JSON, but you'll read more about it.

希望这有助于。

这篇关于如何加载单独的事业部无负载整个页面,并显示加载状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆