-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session lost when there is a pending AJAX request #43
Comments
You will need to modify the code to check if there is an active AJAX request. Load the jquery-idleTimeout-for-testing.js script, https://github.com/JillElaine/jquery-idleTimeout/blob/master/jquery-idleTimeout-for-testing.js, on your page and watch the console (eg: use Firefox Developer Tools https://developer.mozilla.org/en-US/docs/Tools/Web_Console/Opening_the_Web_Console ) to see the output. This is very useful for debugging & understanding how the script works. Next, modify the You'll probably want to 'comment out' many of the extra 'console.log' outputs to focus only on the outputs you care about.
Please report back. Thank you. |
Great work and thanks a lot for your timely reply. It is working somehow as expected, that is, it keeps on waiting while there is an active AJAX connection. It is obvious here that;
Can we therefore reset Your help would be greatly appreciated. |
Ah, yes, in the
|
Thanks very much for your assistance. It is now working to expectation. |
You could likely simplify the .js files and just have one for both testing and debugging by replacing console.logs with a helper / wrapper function - example below.
Then you can leave all debugging / testing code in place and just toggle a single property to indicate whether debugging data is needed.
I use this same logic in all my server side and client side code. Having 2 files makes things more time consuming to develop, test and debug.
Hope this helps.
Richard Hetherington
var logger = {}
// Assign logLevel of between 0 (Disabled) and 4 (Error)
// 0 will disable logging, 1 will log all 4 types, 2 will log info, warn and error, 3 will log warn and error and 4 will log error only
logger.logLevel = 0;
// https://developer.mozilla.org/en-US/docs/Web/API/Console
// Check whether window.console is available before calling it !!
logger.debug = function(msg) {
if ( window.console && logger.logLevel == 1 ) {
console.log( getTime(true) + " - [Debug] - " + msg );
}
}
logger.info = function(msg) {
if ( window.console && logger.logLevel >= 1 && logger.logLevel <= 2 ) {
console.info( getTime(true) + " - [Info] - " + msg );
}
}
logger.warn = function(msg) {
if ( window.console && logger.logLevel >= 1 && logger.logLevel <= 3 ) {
console.warn( getTime(true) + " - [Warn] - " + msg );
}
}
logger.error = function(msg) {
if ( window.console && logger.logLevel >= 1 && logger.logLevel <= 4 ) {
console.error( getTime(true) + " - [Error] - " + msg );
}
}
From: feldenla [mailto:[email protected]]
Sent: 02 March 2017 10:25
To: JillElaine/jquery-idleTimeout
Cc: Subscribed
Subject: Re: [JillElaine/jquery-idleTimeout] Session lost when there is a pending AJAX request (#43)
Thanks very much for your assistance.
It is now working to expectation.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#43 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAa7jlDT2VGNAAABi2XxnV8vgMceK7Mdks5rhpj6gaJpZM4MP1jT>.
|
Sorry left out the getTime function :
function getTime(l_blnIncludeMilliseconds) {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var milliseconds = now.getMilliseconds();
if ( hours.toString().length == 1 ) {
hours = '0'+hours;
}
if ( minutes.toString().length == 1 ) {
minutes = '0'+minutes;
}
if ( seconds.toString().length == 1 ) {
seconds = '0'+seconds;
}
if ( l_blnIncludeMilliseconds ) {
return hours + ':' + minutes + ':' + seconds + ':' + milliseconds;
} else {
return hours + ':' + minutes + ':' + seconds;
}
}
From: Richard Hetherington
Sent: 02 March 2017 10:31
To: 'JillElaine/jquery-idleTimeout'; JillElaine/jquery-idleTimeout
Cc: Subscribed
Subject: RE: [JillElaine/jquery-idleTimeout] Session lost when there is a pending AJAX request (#43)
You could likely simplify the .js files and just have one for both testing and debugging by replacing console.logs with a helper / wrapper function - example below.
Then you can leave all debugging / testing code in place and just toggle a single property to indicate whether debugging data is needed.
I use this same logic in all my server side and client side code. Having 2 files makes things more time consuming to develop, test and debug.
Hope this helps.
Richard Hetherington
var logger = {}
// Assign logLevel of between 0 (Disabled) and 4 (Error)
// 0 will disable logging, 1 will log all 4 types, 2 will log info, warn and error, 3 will log warn and error and 4 will log error only
logger.logLevel = 0;
// https://developer.mozilla.org/en-US/docs/Web/API/Console
// Check whether window.console is available before calling it !!
logger.debug = function(msg) {
if ( window.console && logger.logLevel == 1 ) {
console.log( getTime(true) + " - [Debug] - " + msg );
}
}
logger.info = function(msg) {
if ( window.console && logger.logLevel >= 1 && logger.logLevel <= 2 ) {
console.info( getTime(true) + " - [Info] - " + msg );
}
}
logger.warn = function(msg) {
if ( window.console && logger.logLevel >= 1 && logger.logLevel <= 3 ) {
console.warn( getTime(true) + " - [Warn] - " + msg );
}
}
logger.error = function(msg) {
if ( window.console && logger.logLevel >= 1 && logger.logLevel <= 4 ) {
console.error( getTime(true) + " - [Error] - " + msg );
}
}
From: feldenla [mailto:[email protected]]
Sent: 02 March 2017 10:25
To: JillElaine/jquery-idleTimeout
Cc: Subscribed
Subject: Re: [JillElaine/jquery-idleTimeout] Session lost when there is a pending AJAX request (#43)
Thanks very much for your assistance.
It is now working to expectation.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#43 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAa7jlDT2VGNAAABi2XxnV8vgMceK7Mdks5rhpj6gaJpZM4MP1jT>.
|
Thanks for the feedback, feldenla. Glad it's working. And thanks for the suggestions & great code, rhetherington. For some time (years now), I wished I had the focus to fix up my plugin. I too want to combine the debugging & iframe scripts into one main, unminimized scripts. There are also a couple of bug fixes that need to be included. I am not able to do this work now, but perhaps in the future. |
Thanks for the plugin.
However, I have a long running script that takes longer than the
idleTimeLimit
that I set and hence the plugin logs out the user when theidleTimeLimit
is reached.I would therefore like to know if the plugin can detect an active AJAX request and wait for it to complete before the idle timer begins, that is, can active AJAX request be detected as an active event.
The text was updated successfully, but these errors were encountered: