473,509 Members | 7,333 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?onsid=+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 8602
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
3727
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...
2
2399
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...
1
1390
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:...
2
1744
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...
4
2274
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...
20
2255
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
3102
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...
53
8316
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...
3
4015
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() { ...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
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...
0
7416
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...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5656
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,...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
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...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.