Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
jQuery Loading Status
Old 09-13-2008, 09:58 PM jQuery Loading Status
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Simple question..

When I perform the jQuery .load function.. is there a way to display some sort of loading div, image, or symbol while it loads that page in the specified div?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
 
Register now for full access!
Old 09-13-2008, 10:07 PM Re: jQuery Loading Status
thehuskybear's Avatar
Ultra Talker

Posts: 362
Name: Sam
Location: Tucson, AZ
Trades: 1
What are you loading and when? What I do is initially hide the item and show a loading div with a class that gives it a loading gif as the background image. Then from within the load function, remove the loading class or hide the div and show the item. I can provide a sample if you need one
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
thehuskybear is offline
Reply With Quote
View Public Profile Visit thehuskybear's homepage!
 
Old 09-13-2008, 10:31 PM Re: jQuery Loading Status
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Yes please
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 09-13-2008, 11:00 PM Re: jQuery Loading Status
thehuskybear's Avatar
Ultra Talker

Posts: 362
Name: Sam
Location: Tucson, AZ
Trades: 1
Ok, lets say you are waiting for a image to load...

Your code would look something like this:

HTML Code:
<html>
<head>
    <title>Page Name</title>

    <style>
    <!-- 

         /** Your loading class **/

         .loading{
             background-image: url('images/loading.gif');
          }
    
    //-->
   </style>

   <script>
    <!-- 
    $(document).ready(function()
    {
         // Add loading class to box div
         $('div#box').addClass('loading');
  
         // Create the image
         var myIMG = new Image();

         $(myIMG).load(function()
         {
             // Hide the image
             $(this).hide();
             
             // Remove loading class
             $('div#box').removeClass('loading');

             // Show the image
             $(this).show();
            
             // Add the image to the box div..
             $('div#box').html($(this));

         }).attr('src','images/myIMG.jpg');
    });
   //-->
   </script>

</head>
<body>

<div id="box"></div>

<!-- Other stuff here.....................................  -->

</body>
</html>
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Last edited by thehuskybear; 09-13-2008 at 11:07 PM..
thehuskybear is offline
Reply With Quote
View Public Profile Visit thehuskybear's homepage!
 
Reply     « Reply to jQuery Loading Status
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46528 seconds with 12 queries