Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

Problem with show - hide loader

Hello experts.
I have a problem showing the carloader in the code below.
The page i'm loading in  the itemsholder div is working but before that i don't get the carloader div shown.
Any help?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
  <ul  class="ui-tabs-nav myitems">
     <li id="li_category2">
      <a href="http://test.com/customer_items/items.cfm?category=2">
       <span>test&nbsp;<span class="recc">(4)</span></span>
      </a>
     </li>
     <li id="li_category13">
      <a href="http://test.com/customer_items/items.cfm?category=13">
       <span>test2&nbsp;<span class="recc">(3)</span></span>
      </a>
     </li>
   </ul>
<div id="carloader" class="carloader" style="display:none;"><center><br><br><br><br><br><img src="http://test.com/img/carloader.gif"></center></div>
   <div id="itemsholder"></div>
   <script type="text/javascript" language="javascript" src="http://test.com/js/jquery-1.6.2.min.js"></script>
   <script type="text/javascript">
 $(function() {
	$("ul.myitems li").click(function(e) {
		e.preventDefault();
        var activeTab = $(this).find("a").attr("href");
		var tabNumber = $("ul.myitems li").index(this) + 1;
		$("#carloader").show();
		$("#itemsholder").load(activeTab);
		$("#carloader").hide();
    });
});
 </script> 
</body>
</html>

Open in new window

0
Panos
Asked:
Panos
  • 2
1 Solution
 
mattjp88Commented:
load is async.  When you call load, you should hide the carloader div when it completes.  See the documentation here: http://api.jquery.com/load/

Call load like this and remove the hide() command from live 31

$("#itemsholder").load(activeTab,{},function(){
$("#carloader").hide();
});

Open in new window

0
 
PanosAuthor Commented:
Thank you .It is working now.
0
 
PanosAuthor Commented:
Thank you.
regards
panos
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now