PDA

View Full Version : showing progress problem


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 ===========

A1ien51
03-27-2008, 10:02 PM
It would help if you used code tags so the format stayed intact.

Are you sure it is going into the statmenet xmlHttp.status == 200

Have you tried to debug the code using Firebug in firefox or add alert statemenets to see if the code is being called?

Eric

dare2win
03-27-2008, 10:32 PM
yeah I get a 'responsestatus' 200 and 'responsestatustext' "OK" and the object returns everything as it should .... just won't turn off that div content ...aauugh!!

dare2win
03-28-2008, 04:18 AM
ok here's an update
moved the script into the document proper...not as an external call (i.e; src="hellscript.js") and it worked.

any insight to why??

I can live with it for now (i will sleep tonight) but would like to have it as an external call eventually.

Thanks Alien51 for replying

A1ien51
03-28-2008, 04:42 AM
Your external js file could have been cached. Clear the cache and see if it works.

Eric

dare2win
03-28-2008, 03:02 PM
yeah Eric

caching is an issue
have stopped page caching with (asp/vbscript)
response.CacheControl= "no-store"
response.AddHeader "Pragma", "no-cache"
response.expires=-1

but likely still won't prevent a js cache .. correct?

dare2win
03-28-2008, 03:09 PM
hmmm, propably I should WANT to cache js for performance issues however.

looking for a perfect world.

A1ien51
03-28-2008, 03:56 PM
You want the js files to be cahced. You should add a qs value to the end of the file when you change it.

src="foo.js?ver=213"

Eric