alcani
asked on
Javascript timer
Hi experts,
I’m looking for a simple way to set a JavaScript timer to pull content from the server session every few minutes to keep the session active only while the browser window remains open.
Thanks for your comments,
I’m looking for a simple way to set a JavaScript timer to pull content from the server session every few minutes to keep the session active only while the browser window remains open.
Thanks for your comments,
look into setInterval
Hi,
You have many ways to call server side code from JavaScript!
JavaScript - http://www.aspsnippets.com/Articles/Calling-server-side-function-from-JavaScript-in-ASP.Net.aspx
jQuery - http://www.codeproject.com/Articles/238866/Invoke-Server-Methods-From-Client-Side-Using-JQuer
ASP.NET - http://msdn.microsoft.com/en-us/library/ms178208.aspx
Calling JavaScript function at Particular intervals - http://www.w3schools.com/jsref/met_win_setinterval.asp
Hope it helps u...
You have many ways to call server side code from JavaScript!
JavaScript - http://www.aspsnippets.com/Articles/Calling-server-side-function-from-JavaScript-in-ASP.Net.aspx
jQuery - http://www.codeproject.com/Articles/238866/Invoke-Server-Methods-From-Client-Side-Using-JQuer
ASP.NET - http://msdn.microsoft.com/en-us/library/ms178208.aspx
Calling JavaScript function at Particular intervals - http://www.w3schools.com/jsref/met_win_setinterval.asp
Hope it helps u...
The example at w3schools isn't what I'd use. They pass a String reference to a function in the setInterval call - I'd do it like this:
<html>
<body>
<input type="text" id="clock" />
<script type="text/javascript">
var int=window.setInterval(
function(){
var d=new Date();
var t=d.toLocaleTimeString();
document.getElementById("clock").value=t;},1000);
</script>
<button onclick="int=window.clearInterval(int)">Stop</button>
</body>
</html>
Why, you ask? Because passing a String of code - or function name - to either setTimeout or setInterval is tantamount to using the evil eval statement.
ASKER
Thanks for your comments,
In fact I would like to every 9 minutes execute a function call “Submit”
Could you help me with the syntax?
In fact I would like to every 9 minutes execute a function call “Submit”
Could you help me with the syntax?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.