dare2win
03-27-2008, 09:19 PM
Want to indicate progress to user.
Using <div id="progress"> with initial visibility: hidden
Can get "progress" to show with :
[document.getElementById("progress").style.visibility = 'visible';]
that's all good.
But I can't seem to return it to hidden state after request is returned (see function statechanged)
perplexed as always
Thanks
=========snip start ===========
var xmlHttp
function showCustomer(str)
{
document.getElementById("progress").style.visibility = 'visible';
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="getnews.asp";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
if(xmlHttp.status == 200)
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
document.getElementById("progress").style.visibility = 'hidden';
}
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
===============snip end ===========
Using <div id="progress"> with initial visibility: hidden
Can get "progress" to show with :
[document.getElementById("progress").style.visibility = 'visible';]
that's all good.
But I can't seem to return it to hidden state after request is returned (see function statechanged)
perplexed as always
Thanks
=========snip start ===========
var xmlHttp
function showCustomer(str)
{
document.getElementById("progress").style.visibility = 'visible';
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="getnews.asp";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
if(xmlHttp.status == 200)
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
document.getElementById("progress").style.visibility = 'hidden';
}
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
===============snip end ===========