catch text returned from server side Ajax call?
catch text returned from server side Ajax call?
bill.martino
Posts: 38Questions: 0Answers: 0
My application is password protected via Coldfusion sessions. These have a life of 20 minutes, when they expire and a user takes an action, they are prohibited and redirected to the login page to login again and renew their session.
My issue is that if a user is idle on the page for a long time, the session times out (as it should), however, when the user goes to go to another page of results for instance, the ajax load triggers but the user is never returned with anything, it just spins.
What I would like to be able to do is, in my file that generates the json for datatables to use, instead of returning json, I would like for it to return a text string such as "session expired" and check for that within the datatables component and redirect the user if needed.
Any suggestions how I can go about this?
My issue is that if a user is idle on the page for a long time, the session times out (as it should), however, when the user goes to go to another page of results for instance, the ajax load triggers but the user is never returned with anything, it just spins.
What I would like to be able to do is, in my file that generates the json for datatables to use, instead of returning json, I would like for it to return a text string such as "session expired" and check for that within the datatables component and redirect the user if needed.
Any suggestions how I can go about this?
This discussion has been closed.
Replies
[code]
"fnServerData": function ( sSource, aoData, fnCallback ) {
// get filter ID
var filter_id = $('#storedFilter_id').val();
// send filter ID
aoData.push(
{ "name": "filter_id", "value": $.trim(filter_id) }
);
$.getJSON( sSource, aoData, function (json) {
// check for expired session being returned, if so, send the user back to the login page
if(json.error == 'expired'){
jAlert('You session has timed out, click OK to return to the login screen','Session Timeout', function(r) {
document.location.href='index.cfm?fuseaction=login.form';
});
}
else{
fnCallback(json)
}
} );
}
[/code]