Andy-H Posted February 11, 2012 Share Posted February 11, 2012 var user = { userID : null, sessID : null, login : function( user, company, pass ) { $.getJSON(APIServer, { 'method' : 'login', 'username' : user, 'company' : company, 'password' : pass }, function(response) { if ( APIresponse.error(response) == false ) { this.userID = response.userID; this.sessID = response.sessID; this.devices.load(); $('#blackout, #logincontainer').fadeOut('fast', function() { $('#login .pass').val(''); $('#device_container').slideDown('fast', function() { $('#map').css('bottom', $('#device_container').css('height')); $('#map').mapping('trigger', 'resize'); }); }); } }); }, logout : function() { this.userID = null; this.sessID = null; APIresponse.error({qry : 'LOGIN'}); }, devices : { load : function() { $.getJSON(APIServer, { 'method' : 'getDevices', 'userID' : this.userID, 'sessID' : this.sessID }, function(response) { console.log(response); }); } } } Just thought I'd try it to see if it worked, basically I only want the devices object to be accessible via the user object, is this possible? Link to comment https://forums.phpfreaks.com/topic/256862-cannot-call-method-load-of-undefined/ Share on other sites More sharing options...
Andy-H Posted February 11, 2012 Author Share Posted February 11, 2012 var user = { userID : null, sessID : null, login : function( user, company, pass ) { var me = this; $.getJSON(APIServer, { 'method' : 'login', 'username' : user, 'company' : company, 'password' : pass }, function(response) { if ( APIresponse.error(response) == false ) { me.userID = response.userID; me.sessID = response.sessID; me.devices.load.call(me); $('#blackout, #logincontainer').fadeOut('fast', function() { $('#login .pass').val(''); $('#device_container').slideDown('fast', function() { $('#map').css('bottom', $('#device_container').css('height')); $('#map').mapping('trigger', 'resize'); }); }); } }); }, logout : function() { this.userID = null; this.sessID = null; APIresponse.error({qry : 'LOGIN'}); }, devices : { load : function() { $.getJSON(APIServer, { 'method' : 'getDevices', 'userID' : this.userID, 'sessID' : this.sessID }, function(response) { console.log(response); }); } } } I was calling this inside getJSON, *facepalm Link to comment https://forums.phpfreaks.com/topic/256862-cannot-call-method-load-of-undefined/#findComment-1316868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.