473,387 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

AJAX Loading Tab Doesn't Display

I would like have a little "loading..." tab not unlike the one that
gmail uses and I would like to display that tab while an ajax call is
made. The javascript to display the tab works. The javascript to hide
the tab works. But when I put the two together inside the function
that calls the ajax service, they don't work.

What seems to happen is that calls to change DOM object properties are
queued up, and then all executed simultaneously. That's what it looks
like anyway. Here is some example code:

<html>
<head>
<script language="Javascript">
function showLoading () {
document.getElementById("loading_tab").style.displ ay = "";
}
function hideLoading () {
document.getElementById("loading_tab").style.displ ay = "none";
}

function ajax () {
// show the loading tab
showLoading ();

// do cool ajax stuff (actual ajax code snipped)
// (this code is just to waste some cpu cycles)
for (var I = 0; I < 100000; I++) var X = new Date();

// hide the loading tab
hideLoading ();
}
</script>
</head>
<body onload="hideLoading()">
<div style="background-color:#f00" id="loading_tab">loading...</div>

<form>
<input type=button value="Show Loading Tab" onclick="showLoading()">
<input type=button value="Hide Loading Tab" onclick="hideLoading()">
<input type=button value="Run AJAX Service" onclick="ajax()">
</form>

</body>
</html>

Sep 30 '05 #1
2 2028
ch****************@gmail.com wrote:
What seems to happen is that calls to change DOM object properties are
queued up, and then all executed simultaneously.


Some browsers, IE in particular, won't refresh the UI until a function
exits. So even though you're changing properties inside the function, these
are not shown until the whole function exits.

Instead, you need to look at setTimeout(). Run the first part to show the
tab, then use setTimeout() to run the second part in 10ms or something. The
first function will exit, and your changes will be shown. Then the second
will fire, etc.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Sep 30 '05 #2
That fixes it. thanks.

Sep 30 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: shankwheat | last post by:
I'm experimenting with using a AJAX style "processing" icon. The process I'm running in the background with xmlHttp is intensive and takes a 5--10 secs to complete. Instead of my processing icon...
17
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);"...
7
xNephilimx
by: xNephilimx | last post by:
lHi guys! I'm having a little problem that's getting on my nerves, I couldn't find a solution, I also tryed googling it and I found nothing... (my field of expertise is in AS 2 and 3, but I still...
5
by: simon | last post by:
hello, I have a server set up on my local (home) network and can not get an ajax application to run on the box. it works fine on our developement server and also works fine locally. I...
11
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have run into a situation that if a page/tab that uses the Ajax toolkit (using .net version 3.5) is closed before the Ajax enable controls complete loading, then IE locks up. Does it in both IE7...
8
by: knkk | last post by:
Instead of an id getting its innerHTML changed, the entire page is getting refreshed with this function of mine (you may want to look just at the end of the function where there's an alert): ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.