h0d3nt3uf3l :
i don't get the followed to run. There is a class for devices. In this class I have to get some Variables with a $.get request. This request will get the data from a .php-script which collects the data from a MySQL-Database.
The Error is "this.device is not a constructor". Think it's not found in the functions scope. Can somene give me a hint? Usually I'm home in C#, sorry :)
Help?
var link150 = function() {
//Array zum Sammeln der Devices
this.devices = [];
//#####################
//Definition eines Devices
//#####################
function general_config() {
this.database_id = "";
this.devicename = "";
this.hardware_id = "";
this.serialnumber = "";
this.ip = "";
this.firmware_version = "";
this.model = "";
this.password = "";
}
this.device = function() {
this.database_id = "";
this.devicename = "";
this.username = "";
this.hardware_id = "";
this.fqdn = "";
this.kunde_id = "";
this.location = "";
this.ip = "";
this.defaultPW = "";
this.generalConfig = new general_config(); //TEST
this.generalConfig.model ="EGX150"; //TEST
}
jQuery.ajaxSetup({async:false});
//#####################
//Devices aus Datenbank laden
//#####################
this.loadDevices = function() {
_devices = [];
$.get('php/abfrage.php', {action:'loadDeviceList'}, function(data){
$.each(JSON.parse(data), function(i, item) {
tmp = new this.device();
tmp = {
id: item.id,
hardware_id: item.hd_id,
devicename: item.devicename,
fqdn: item.fqdn,
kunde_id: item.kunde_id,
location: item.kunde_location,
ip: item.ip,
lastsid: item.lastSID
};
_devices.push(tmp);
});
})
.always(function(){
hide_loader();
});
this.devices = _devices;
};
//#####################
//Geräte laden
//#####################
this.loadDevices();
jQuery.ajaxSetup({async:true});
};
waiaan :
is this work?
var _self=this;
this.loadDevices = function() {
_devices = [];
$.get('php/abfrage.php', {action:'loadDeviceList'}, function(data){
$.each(JSON.parse(data), function(i, item) {
tmp = new _self.device();
tmp = {
id: item.id,
hardware_id: item.hd_id,
devicename: item.devicename,
fqdn: item.fqdn,
kunde_id: item.kunde_id,
location: item.kunde_location,
ip: item.ip,
lastsid: item.lastSID
};
_devices.push(tmp);
});
})
.always(function(){
hide_loader();
});
this.devices = _devices;
};