Jump to content

Cannot call method 'load' of undefined


Andy-H

Recommended Posts


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

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.