473,383 Members | 1,896 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,383 software developers and data experts.

AJAX Style processing icon

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
appearing in the page, the page just freezes during the process until
it's finished. Is this the best way to display this kind of icon?
What can I do so this works right? Thanks

function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";
<span id="lblResults" name="lblResults"></span>

Apr 13 '07 #1
10 7961
On Apr 13, 1:28 pm, "shankwheat" <evanbu...@gmail.comwrote:
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
appearing in the page, the page just freezes during the process until
it's finished. Is this the best way to display this kind of icon?
What can I do so this works right? Thanks

function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";

<span id="lblResults" name="lblResults"></span>
Can you post the code where you are opening and sending the
XmlHTTPRequest?

Apr 13 '07 #2
On Apr 13, 1:46 pm, "Jason" <redund...@gmail.comwrote:
On Apr 13, 1:28 pm, "shankwheat" <evanbu...@gmail.comwrote:


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
appearing in the page, the page just freezes during the process until
it's finished. Is this the best way to display this kind of icon?
What can I do so this works right? Thanks
function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";
<span id="lblResults" name="lblResults"></span>

Can you post the code where you are opening and sending the
XmlHTTPRequest?- Hide quoted text -

- Show quoted text -
This is what I'm using. Thanks

function getIndustries()
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Your browser does not support the XMLHttpRequest object.")
return
}
var url="getIndustries.aspx"
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";

// Clear the available listbox of any previous options
document.choiceForm.available.length = 0;

// Split the delimited response into an array
results = xmlHttp.responseText.split(",");

for (var i=0; i < results.length;++i){
addOption(document.choiceForm.available, results[i], results[i]);
}
}
}

function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
Apr 13 '07 #3
On Apr 13, 2:18 pm, "shankwheat" <evanbu...@gmail.comwrote:
On Apr 13, 1:46 pm, "Jason" <redund...@gmail.comwrote:
On Apr 13, 1:28 pm, "shankwheat" <evanbu...@gmail.comwrote:
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
appearing in the page, the page just freezes during the process until
it's finished. Is this the best way to display this kind of icon?
What can I do so this works right? Thanks
function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";
<span id="lblResults" name="lblResults"></span>
Can you post the code where you are opening and sending the
XmlHTTPRequest?- Hide quoted text -
- Show quoted text -

This is what I'm using. Thanks

function getIndustries()
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Your browser does not support the XMLHttpRequest object.")
return

}

var url="getIndustries.aspx"
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

}

function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";

// Clear the available listbox of any previous options
document.choiceForm.available.length = 0;

// Split the delimited response into an array
results = xmlHttp.responseText.split(",");

for (var i=0; i < results.length;++i){
addOption(document.choiceForm.available, results[i], results[i]);

}
}
}

function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);

}
Just an observation, why don't you set the innerHTML of lblResults
right after you send the request and then just check for readyState ==
4.

var url="getIndustries.aspx"
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading
}

function stateChanged()
{
if(xmlHttp.readyState == 4) {
//do stuff
}
}

It will make less work for the browser.

Apr 13 '07 #4
On Apr 13, 2:30 pm, "Jason" <redund...@gmail.comwrote:
On Apr 13, 2:18 pm, "shankwheat" <evanbu...@gmail.comwrote:


On Apr 13, 1:46 pm, "Jason" <redund...@gmail.comwrote:
On Apr 13, 1:28 pm, "shankwheat" <evanbu...@gmail.comwrote:
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
appearing in the page, the page just freezes during the process until
it's finished. Is this the best way to display this kind of icon?
What can I do so this works right? Thanks
function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";
<span id="lblResults" name="lblResults"></span>
Can you post the code where you are opening and sending the
XmlHTTPRequest?- Hide quoted text -
- Show quoted text -
This is what I'm using. Thanks
function getIndustries()
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Your browser does not support the XMLHttpRequest object.")
return
}
var url="getIndustries.aspx"
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading
}
else if(xmlHttp.readyState == 1)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loaded
}
else if(xmlHttp.readyState == 2)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //interactive
}
else if(xmlHttp.readyState == 3)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>";
}
else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("lblResults").innerHTML = "";
// Clear the available listbox of any previous options
document.choiceForm.available.length = 0;
// Split the delimited response into an array
results = xmlHttp.responseText.split(",");
for (var i=0; i < results.length;++i){
addOption(document.choiceForm.available, results[i], results[i]);
}
}
}
function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}

Just an observation, why don't you set the innerHTML of lblResults
right after you send the request and then just check for readyState ==
4.

var url="getIndustries.aspx"
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading

}

function stateChanged()
{
if(xmlHttp.readyState == 4) {
//do stuff
}

}

It will make less work for the browser.- Hide quoted text -

- Show quoted text -
Yes, that makes sense. I implemented your suggestion and it does
load a litle faster but didn't solve the problem with the icon not
appearing. I'm passing quite a bit of data back to the page and it
just freezes until it's done which is all the more reason I need some
cue to the user of what's going on :-)

Thanks

Apr 13 '07 #5
"shankwheat" <ev*******@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr oups.com...
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
appearing in the page, the page just freezes during the process until
it's finished. Is this the best way to display this kind of icon?
What can I do so this works right? Thanks
This has *NOTHING* to do with all the code you have posted. In fact, every single reply
to this thread (aside from mine) is pointless.

At the moment you being your request, make your IMG or DIV, or whatever appear.

When the request returns (as in, is loaded) then make the image disappear. End of story.

-Lost
Apr 14 '07 #6
On Apr 13, 11:42 pm, "-Lost" <missed-s...@comcast.netwrote:
"shankwheat" <evanbu...@gmail.comwrote in message

news:11**********************@p77g2000hsh.googlegr oups.com...
I'm experimenting with using aAJAXstyle"processing"icon. The
process I'm running in the background with xmlHttp is intensive and
takes a 5--10 secs to complete. Instead of myprocessingicon
appearing in the page, the page just freezes during the process until
it's finished. Is this the best way to display this kind oficon?
What can I do so this works right? Thanks

This has *NOTHING* to do with all the code you have posted. In fact, every single reply
to this thread (aside from mine) is pointless.

At the moment you being your request, make your IMG or DIV, or whatever appear.

When the request returns (as in, is loaded) then make the image disappear. End of story.

-Lost
Yea, well, -"Lost", it doesn't work. Thanks for the pointless
suggestion.

Apr 14 '07 #7
"ev*******@gmail.com" <ki*********@gmail.comwrote in message
news:11**********************@y5g2000hsa.googlegro ups.com...
On Apr 13, 11:42 pm, "-Lost" <missed-s...@comcast.netwrote:
>"shankwheat" <evanbu...@gmail.comwrote in message

news:11**********************@p77g2000hsh.googleg roups.com...
I'm experimenting with using aAJAXstyle"processing"icon. The
process I'm running in the background with xmlHttp is intensive and
takes a 5--10 secs to complete. Instead of myprocessingicon
appearing in the page, the page just freezes during the process until
it's finished. Is this the best way to display this kind oficon?
What can I do so this works right? Thanks

This has *NOTHING* to do with all the code you have posted. In fact, every single
reply
to this thread (aside from mine) is pointless.

At the moment you being your request, make your IMG or DIV, or whatever appear.

When the request returns (as in, is loaded) then make the image disappear. End of
story.

Yea, well, -"Lost", it doesn't work. Thanks for the pointless
suggestion.
Just because *you* are incapable of getting it to work does not mean it is impossible.

Thanks for your pointless reply though.

By the way, I have a perfectly working example (in fact, a couple). So, again, *YOU* are
doing something wrong.

I am sorry to hear that you take such offense to valid suggestions though. Next time I'll
just ignore you.

-Lost
Apr 15 '07 #8
VK
On Apr 13, 10:18 pm, "shankwheat" <evanbu...@gmail.comwrote:
if (xmlHttp.readyState == 0)
{
document.getElementById("lblResults").innerHTML = "<img
src='mozilla_blu.gif' alt='loading..please wait'>"; //loading
}
else if(xmlHttp.readyState == 1)
<snip>

In your coding your are assuming that the state changes are going by
the book, "slow and proudly": 0-1-2-3-4

That is hardly ever true for ajaxoids. First of all 0 state is never
to expect: if you could instantiate your ajaxoid then its state is
already 1; if you couldn't then you would get a failure return on the
previous step. The stages 1-2-3 overall a complete bogus, they were
inherited from the original IXMLHTPRequest interface but they serve no
practical purpose.
First of all they are passing so quickly that no DOM interface will
bother to show them (internal delay is too short).
Secondly they rarely go in the numeral order 1-2-3. The most often one
or two of them simply disregarded so never fired.
Thirdly the intermediary states' change is screwed on Gecko. Don't
have bug # right now, so either trust me or don't.
-------------

0-1-2-3 states is a useless "Cargo Cult" add-on remained from the AJAX
early childhood - producers still keeping it because it's documented.
In the programming the only two stages you are dealing with are:
1) success / failure to instantiate your ajaxoid
2) success / failure to arrive to the state 4 (complete)

There is a number of pitfalls on the go. The first one is the graphics
context update delay, see
http://groups.google.com/group/comp....470812c5e4d3b5

Another one is that Gecko reports state 4 in case of network error as
well, but in this case any attempt to access ajaxoid properties leads
to run-time error. By "network error" I don't mean "Server not
responding" and so, but lower level protocol errors.

Overall while the principles of ajaxoid programming are very simple,
the amount of details to take into account is usually exceeding the
provided programmer's knowledge and experience. This is why I
regularly suggest to not take the risk of re-inventing the wheel but
take a time proved library like http://www.ajaxtoolbox.com

Apr 15 '07 #9
"VK" <sc**********@yahoo.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
Overall while the principles of ajaxoid programming are very simple,
the amount of details to take into account is usually exceeding the
provided programmer's knowledge and experience. This is why I
regularly suggest to not take the risk of re-inventing the wheel but
take a time proved library like http://www.ajaxtoolbox.com
So JavaScripters should just rely on an existing library instead of learning the proper
way in which to do something?

-Lost
Apr 16 '07 #10
VK
On Apr 16, 7:12 am, "-Lost" <missed-s...@comcast.netwrote:
JavaScripters should just rely on an existing library instead of learning the proper
way in which to do something?
AjaxRequest is well documented, so one is welcome to study what, how
and why is being made:
http://www.ajaxtoolbox.com/request/source.php

About the "learning curb":

Everything has its time and its place. Some people prefer the
practical learning, so they take a rather complicated task and hit the
wall until it's working - by obtaining the necessary knowledge on the
go from available sources. If OP decided to learn JavaScript over
making a well working ajaxoid then it's fully OK. If OP needs a
working interface right now for a live project then the "learning
curb" may take several months with all oops reported by frustrated
customers and not by an in-house QA. That can become a way too
expensive learning experience.

1) run-time error on reading XHR property after network errors
(despite status=400)
2) send null or "" for GET sensibility for some UA versions
3) GET request length limit on different IE versions
4) multiple async requests caveats which would be a separate nested
list right here

How much time does it take to simply _arrive_ to these questions out
of foggy error reports from your customers?

In this respect AjaxRequest is not really a "library" like say
prototype.js
It is merely a sophisticated interface over all kind of bugs, under-
implementations and limitations of different IXMLHTTPRequest/
XmlHttpRequest implementations.

Apr 16 '07 #11

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

Similar topics

1
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
10
by: trpost | last post by:
I am using ajax / php where I am looking up some info from the database and populating a select list dynamically, however I am running into some sort of size limitation with the ajax.response...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
1
by: JWHIT | last post by:
I created a map application which works fine with regular aspx and a meta refresh. I would like to have the map itself update independently using ajax. (Sorry on the long post, I just started...
1
by: bdbeames | last post by:
I have a page with google maps up and running. When a user clicks on a location from the map I would like to populate a drop down with data from the database related to that location. I have it up...
4
by: slebetman | last post by:
On Jun 5, 9:36 pm, sheldonlg <sheldonlgwrote: You can of course use closure to pass the required parameter: var hideIt; // the variable you wish to pass ajax.onreadystatechange = function () {...
22
by: sheldonlg | last post by:
I am looking for a clean solution to a problem that I solved in, what I call, a "dirty" way. Here is what I want to do. I have a dropdown list. Clicking on an item in the dropdown list invokes...
10
by: dkyadav80 | last post by:
<html> /// here what shoud be java script for: ->when script run then not display all input text field only display selection field. ->when user select other value for institute only this...
3
by: fkhowaja | last post by:
i want to show the property details and there status (APPROVED, REJECTED, PENDING) the whole result is coming through ajax now i want that if i click on Approved icon or Pending icon or Rejected icon...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.