Hi, I have the following repeating code in a web page:
<a href="#null" onclick="getdetails('111_<
%=thefirst
counter%>'
)"/><%=the
firstcount
er%></a></
td>
<div id="111_<%=thefirstcounter
%>" style="display:none;">
<img src="images/loading.gif" /> <font color="red"> Executing, please wait</font>
</div>
part of the javascript is as follows:
var ImRunning = false;
function getdetails(counter)
{
if (!ImRunning) {
ImRunning = true;
xmlHttp=GetXmlHttpObject()
;
if (xmlHttp==null) {
alert ("Your browser does not support AJAX!");
ImRunning = false;
return;
}
var url="getdetails.asp";
xmlHttp.onreadystatechange
=stateChan
ged;
xmlHttp.open("GET",url,tru
e);
theCounter = counter;
showHide();
xmlHttp.send(null);
}
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
var whatWasReturned = xmlHttp.responseText;
var pos = whatWasReturned.indexOf("v
vvvv");
if (pos == -1)
{
document.getElementById(th
eCounter).
innerHTML=
xmlHttp.re
sponseText
;
ImRunning = false;
}
else
{
ImRunning = false;
window.location = "
http://www.google.com";
}
}
}
function showHide()
{
if (theCounterNextNext == "")
{
window.location.href = "
http://www.google.com"
}
else
{
if (document.getElementById(t
heCounter)
.style.dis
play == 'none')
{
document.getElementById(th
eCounter).
style.disp
lay = '';
}
else
{
document.getElementById(th
eCounter).
style.disp
lay = 'none';
}
}
}
One thing I've noticed is that whether you expand or collapse each div, the page getdetails.asp gets executed. How can I adjust the code above so that the getdetails.asp page is only executed when I'm exanding the div?
Start Free Trial