View Full Version : Returning data from Ajax call in Ext.onReady

6 May 2014, 3:59 PM
I have an Ext JS app and I want to check on the backend if the session is invalid every time a user clicks on a link within the app. These two Ajax calls are both in Ext.onReady, I would like to clean up this code but I need to check for timeout every click, the second Ajax call is only called upon logging in if it were by itself. This is in my app.js also.

Ext.Ajax.on('requestcomplete', function(conn, response, options, options) {
if(!isSessionValid()) {
window.location.href = '?login_status=timeout';

function isSessionValid() {
url: contextRoot + '/isSessionValid.htm?alt=json',
method: 'get',
success: function(response, options) {
var isValid;
var o = Ext.decode(response.responseText);
(o != loggedInUser.username) ? isValid = false : isValid = true;
return isValid;
failure: function(response, options) {

Obviously isSessionValid will return undefined.. is there a workaround to get the data I need and not have my ajax call continuously calling?

6 May 2014, 10:44 PM
See the comments here: http://stackoverflow.com/questions/23505430/returning-data-from-ajax-call-in-ext-onready