?
Solved

Getting Error on recursion with settimeout?

Posted on 2011-10-05
8
Medium Priority
?
234 Views
Last Modified: 2012-06-27
I get an error of "omniKeepSessionAlive is not defined" on the internal settimeout of the function:

setTimeout("omniKeepSessionAlive()",50000);

And I don't know why? Any ideas?
function omniKeepSessionAlive(){

		if (typeof(s_ea.prop5)!="undefined"){
		   var p5Val = "ebisu"
  		   if(p5Val.indexOf(s_ea.prop5.toLowerCase())!=-1){
		       if(!timerStarted){
			     initSessionTimerValues();
				 timerStarted = 1;
			   }
			   var currTime = getCurrMin();
			   if (targetMinCnt == currTime){
			   document.write("*** CUSTOM LINK SENT *** targetMinCnt: "+ targetMinCnt + " <--> currTime: "+ currTime+ "<br>");
			     timerStarted = 0;
				 omniLinkCall('extendSession');
				}
				document.write("targetMinCnt: "+ targetMinCnt + " <--> currTime: " + currTime + "<br>");
		   	  alert("settimeout");
			  setTimeout("omniKeepSessionAlive()",50000);

		   }
  		    
		 }
};
setTimeout("omniKeepSessionAlive()",10000);//kicks off timer onload

Open in new window

0
Comment
Question by:894359
  • 4
  • 3
8 Comments
 

Author Comment

by:894359
ID: 36920585
If you want rest of code then:

var currStartMin = -1;//current start min for session extention
var targetMinCnt = -1;//target min session extention
var timerStarted = 0;//flag for sesiin timing started

function initSessionTimerValues(){

currStartMin = getCurrMin();
var sessionTimeMin = 28;
var timeThreshold = 31
var minAdj = 32;

if (currStartMin <= timeThreshold){
  targetMinCnt = currStartMin + sessionTimeMin;
}else{
  targetMinCnt = currStartMin - minAdj;
}
};

function getCurrMin(){
var currentTime = new Date()
var minStart = currentTime.getMinutes();
return minStart;
}
0
 
LVL 9

Expert Comment

by:CCSOFlag
ID: 36920615
Which call are you getting the error on?  The internal call or the call after the function
0
 

Author Comment

by:894359
ID: 36920800
internal call but I noticed if I removed my testing code (doc writes and alerts) I don't get the error any more?!?!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 61

Accepted Solution

by:
HainKurt earned 1000 total points
ID: 36920820
I dont see any issue

have a look at this tiny sample

do you have any link to produce the issue?
<script>
function a(){
  alert('a');
  setTimeout("a()",3000);
}
a();
</script>

Open in new window

0
 
LVL 9

Expert Comment

by:CCSOFlag
ID: 36920822
O.o

Really?  I don't see anything wrong with the said lines, so not sure why they would cause anything.
0
 
LVL 9

Assisted Solution

by:CCSOFlag
CCSOFlag earned 1000 total points
ID: 36920832
Take those lines out one at a time and see which one is causing the error.
0
 

Author Closing Comment

by:894359
ID: 36920875
For some reason it was the document writes causing the issue?  Oh well!
0
 
LVL 9

Expert Comment

by:CCSOFlag
ID: 36920880
well at least you figured out there's nothing wrong with the function call. :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question