AJAX & JS problem

Starfinder

Elite
Joined
Jan 31, 2005
Posts
3,062
Location
Denmark
Society
Planet Express
Avatar Name
Ms. Kazzza 'Starfinder' Milla
Hey hey... Im making a javascript thats using some AJAX features, which when it works is really nice.. I just got a small problem.. The ajax uses an asp session to determine what to run so the first part of the question is; how to do this in a nice way? As it is now, its kind of "brute". The second part of the question is that when the session times out the AJAX generates an error and places new instances of the ajax in a new variable (i think).. which causes memory leaks.. If you renew you session (IE click arround on the page) its fine, but if you stay on the same page until the session times out it takes up 200 kb ram pr second. - you do the math...

So how to solve this.. Below is the javascript.



<script language="JavaScript"><!--
// v4 compatible:
var myAjax;
var temp;
var str;
function doSomething()
{
str = 'st' + '<%=session("UID")%>'
if (str != 'st')
{
myAjax = new Ajax.PeriodicalUpdater('mailResult', 'liveCheckMail.asp?ID=<%=session("UID")%>', {asynchronous:true, frequency:2, method:'post', evalScripts:true });
}
if (str == 'st')
{
window.location = "http://www.portalEntropia.com/Logout.asp";
}
}

function scrol()
{
setInterval('scrol()',50000)
if (document.getElementById('mailResult') != null)
{
if(parseInt(document.getElementById('mailResult').innerHTML) >= 1)
{
temp = slide()
}
}
}

doSomething()
//scrol()
setInterval('scrol()',10000)
//-->
</script>
 
Back
Top