473,569 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

loading image while jquery is loading

38 New Member
Trying to get a loading image to spin while the query is loading.

I can get the data div to fade in, but I can't seem to figure out how to get the gif while the query is loading.

I'm using two divs..

id "entrytext" is where the data will load into and has a display:none

contentLoading is the loading gif div.

Currently using jquery with this script.
Expand|Select|Wrap|Line Numbers
  1. $(document).ready(function(){
  2. $("#entrytext").fadeIn('slow');  //Sub-form query results go here.
  3. $("tr:odd").addClass("highlight");  //Table alternates
  4.  
  5.  
I tried using this information, but I'm unable to translate the example's external page load into something that works for me.

Expand|Select|Wrap|Line Numbers
  1. jQuery(function($) {   
  2. $("#contentArea").load("test.php");   
  3. });   
  4.  
  5. $().ajaxSend(function(r,s){   
  6. $("#contentLoading").show();   
  7. });   
  8.  
  9. $().ajaxStop(function(r,s){   
  10. $("#contentLoading").fadeOut("fast");   
  11. });   
  12.  
instead of an external test.php I've got a combo box that sends viewons.php?ons id=+this.value to itself.

Here's a link to what I'm working on. (The data is NOT REAL)

Anyone mind helping me understand what more I should do?

Respectfully,
Aaron
Aug 17 '09 #1
6 8607
gits
5,390 Recognized Expert Moderator Expert
i don't see where you are doing an AJAX-request in your example?

kind regards
Aug 18 '09 #2
aaronkmar
38 New Member
In other words... "You're doing it wrong!" ?
I'll keep googling...
Aug 18 '09 #3
gits
5,390 Recognized Expert Moderator Expert
when you do an ajax-request that request is async and you could show a loading-image or something like that ... since that avoids a page-reload and the browser is executing the request in a way so that it is 'free' to process other things in the meantime. when you do a plain old page-reload then that is sync and the browser waits for the result and is blocked ... so you might use jQuery's ajax-class to retrieve the data ...

kind regards
Aug 18 '09 #4
aaronkmar
38 New Member
Thanks again gits.
It looks like I'm trying to do this without ajax, only jquery.

I'm very close to working it out, all I need to figure out is how to show the loading image while the DOM is being prepared instead of waiting until the page is ready to hide the load image and fade in the results div.

here's the code
Expand|Select|Wrap|Line Numbers
  1. $(document).ready(function(){
  2. var loadImg = $('#loadImg');
  3. loadImg.show();
  4. var linResults = $('#entrytext');
  5. linResults.hide();
  6. loadImg.hide(1000);
  7. $("#entrytext").fadeIn(2000);
  8. $("tr:odd").addClass("highlight");
  9. });
  10.  
  11.  
I'll keep trying to figure it out.
Link to the page is here.

Respectfully,
Aaron
Aug 18 '09 #5
aaronkmar
38 New Member
I got it working!
No idea what I did
But at least it's working as intended.

/scratches head...being a n00b really sucks.
Aug 18 '09 #6
gits
5,390 Recognized Expert Moderator Expert
as far as i could see you reload the page on change of the select. when the page is loaded you show the loading gif and hide the contentarea for a specific amount of time. but the data is already in the page ... since it is delivered during the page reload?

kind regards
Aug 18 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3733
by: Adrian MacNair | last post by:
Hi, I created an image gallery which displays 63 images in a slideshow. The problem is that the show was slow because each image loaded one at a time during the show. No problem right? I just did a preload script. But then the user has to sit for 5 minutes waiting for 63 images to download! My images are about 640x480 and average 100kb. Is...
2
2405
by: corymac | last post by:
Hello, I've customized the panview code to accommodate what I want it to do, but I'm having a problem with it in IE. Firefox works fine. Panning the image in IE doesn't work and I think it has something to do with scrollTop, but i have no idea what to do to fix it. If I take the pan image code out of the html page and have it by itself...
1
1392
by: Faraz.ya | last post by:
Hi, When I include an image in a div and add a sliding hide effect on the div to close it, my image in the div don't disappear in internet explorer. I think it's the best if you take a look at: http://mkweb123.web.aplus.net/kayaks.php to see exactly what I mean. If you click on the first boat ( the yellow one) and then click on another boat,...
2
1749
by: dysfunct | last post by:
Question for those who know more about this stuff than I: I'm using jQuery on an interactive site, essentially it creates widget type things from rss feeds. So users can add and close these widgets and yada yada. The problems is, a lot of the widgets end up having a lot of images in them and I've noticed that upon closing the widget, which...
4
2275
by: tetris | last post by:
I have this little code wich is working quite good, it makes a slide show on the body background, anyone could guide me on how to add a fade effect as a transition between the images?? var Pic = new Array('cow2.jpg','cow3.jpg','cow4.jpg'); j=0; p=Pic.length;
20
2266
by: Aaron Gray | last post by:
There does not seem too be anyway to test if two jQuery references are the same element. Given :- ... <div id="1"></div .... Then :- alert( $("#1") == $("#1"))
26
3116
by: RobG | last post by:
Do some of the regulars here need to re-think their (sometimes strident) opposition to libraries? Both Microsoft and Nokia have announced support for jQuery. It seems to have gained quite a bit of momentum, can it be considered a reasonable choice for those who want to use a full-featured, well supported library? <URL:...
53
8347
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script language="javascript" type="text/javascript">
3
4024
by: jmeyer5csc | last post by:
i am using jquery to display a working... div to show the user that the query is doing something. to show.... Sys.Application.add_init(function() { $addHandler($get('ctl00_ContentPlaceHolder1_LinkButtonQuickReport'), 'click', function() { $('#working').show(); }); }); to hide...
0
7615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.