473,763 Members | 5,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript w/My AJAX Callback - Why Doesn't This Work Correctly?

Hey guys, here's what I have...

To help manage browser windows with session state on the server, I
have some javascript code in one of my master pages that gets planted
into most (content) pages on my site...

<script type='text/javascript'>
var sessionTimer;
function StartSessionTim er()
{
sessionTimer =
window.setTimeo ut('RedirectToS essionTimedOutP age()', 600000);
}
function RestartSessionT imer()
{
clearTimeout(se ssionTimer);
StartSessionTim er();
}
function RedirectToSessi onTimedOutPage( )
{
window.location = '/SessionTimedOut .aspx';
}
</script>

For most pages I perform AJAX xml-http callbacks to the server with
UpdatePanels. Then I fire off the 'RestartSession Timer' client-side
javascript function when the asynchronous call returns from the
server.

The idea is, I set up the code above to handle redirecting browsers to
the
'SessionTimedOu t.aspx' page when the value of 600000 milliseconds
(ten minutes) elapses.

But when I do an AJAX callback, I must *reset* the value,
so that the redirect occurs ten minutes from *then*. I have
successfully set up the code to call the client-side
'RestartSession Timer'
function when the callback finishes, but the value of 600000
apparently is never reset. It always retains (what is remaining) of
the original value.
An example: I load the page and then after about nine minutes (one
minute prior to the 'setTimeout' expiration,) I do actions that make
that
make the callback and that call the 'RestartSession Timer' function in
the browser. However the page still redirects only a minute later ...
instead of in
*another* ten minutes as intended.
What am I doing wrong here?

Nov 1 '07 #1
1 2024
if you are using cookie based sessions, then update panels' xmlhttprequest do
not update the browser cookie, so after the cookie timesouts, the update
panel request will not contain the session cookie and your page will not have
session (even though the session is still alive on the server).

most likely the update panel is getting an error back, and not calling you
reset timer event.
-- bruce (sqlwork.com)
"Joey" wrote:
Hey guys, here's what I have...

To help manage browser windows with session state on the server, I
have some javascript code in one of my master pages that gets planted
into most (content) pages on my site...

<script type='text/javascript'>
var sessionTimer;
function StartSessionTim er()
{
sessionTimer =
window.setTimeo ut('RedirectToS essionTimedOutP age()', 600000);
}
function RestartSessionT imer()
{
clearTimeout(se ssionTimer);
StartSessionTim er();
}
function RedirectToSessi onTimedOutPage( )
{
window.location = '/SessionTimedOut .aspx';
}
</script>

For most pages I perform AJAX xml-http callbacks to the server with
UpdatePanels. Then I fire off the 'RestartSession Timer' client-side
javascript function when the asynchronous call returns from the
server.

The idea is, I set up the code above to handle redirecting browsers to
the
'SessionTimedOu t.aspx' page when the value of 600000 milliseconds
(ten minutes) elapses.

But when I do an AJAX callback, I must *reset* the value,
so that the redirect occurs ten minutes from *then*. I have
successfully set up the code to call the client-side
'RestartSession Timer'
function when the callback finishes, but the value of 600000
apparently is never reset. It always retains (what is remaining) of
the original value.
An example: I load the page and then after about nine minutes (one
minute prior to the 'setTimeout' expiration,) I do actions that make
that
make the callback and that call the 'RestartSession Timer' function in
the browser. However the page still redirects only a minute later ...
instead of in
*another* ten minutes as intended.
What am I doing wrong here?

Nov 1 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2322
by: NH | last post by:
Hi, I am trying to minimise postback in my web app. I have a number of inter-dependent dropdowns, an onselectedindexchange event fires for each one which obviously causes a postback. Is there a way I can get all my data from a dataset\datareader into some javascript arrays and then use client side events to handle the inter-dependent dropdowns? Any code examples? I know in ASP.Net 2.0 there is a feature called "Client Callback" which...
4
1744
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, is there a way to run my javascript method on every async postback? thanks, rodchar
3
3383
by: pablosuk78 | last post by:
Dear coders, I'm facing a problem and after few research I found that many ppl were looking around for the same solution, hope someone more expert than me could give a good help. I created an AJAX function that i.e. on click does a request to a server and show into a specified tag the results (well until here is something eveyone would do with AJAX)... the point is that the result is something like the this: i.e. <!-- this is the...
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.