0

Hi I have a problem handling the return of the success function of my jQuery post in my object constructor, I'm sure the "return" isnt at the right place but cant seems to figure out the solution. The debug console log, shows me what im looking in my methods but when i run the code it isnt. Here's the code Thanks for your help

var url = "http://192.168.1.125:8083/ZWaveAPI/Run/";

function device(id,instances,commandClasses){
    this.id = id;
    this.instances = instances;
    this.commandClasses = commandClasses;
    //console.log(this.device);
    //console.log(this.commandClasses);
    this.deviceUpdate = function(){
        $.ajax({
            type: "POST",
            url: ""+url+"devices["+this.id+"].instances["+this.instances+"].commandClasses["+this.commandClasses+"].Get()",
            success: function(textStatus){
                console.log(textStatus);
                return textStatus;
                            },
            dataType: "json"
        });
    };
    this.deviceData = function(){
        $.ajax({
            type : "POST",
            url : ""+url+"devices["+this.id+"].instances["+this.instances+"].commandClasses["+this.commandClasses+"].data",
            success : function(data){
                var dataResponse = {
                        deviceName : data.name,
                        levelValue : data.level.value
                };
                console.log(dataResponse);
                return dataResponse;
            },
            dataType : "json"
        });
    };
};


$(document).ready(function(){
    var device3Update = new device(3,0,38);
    device3Update.deviceUpdate();
    console.log(device3Update);

    var device3Data = new device(3,0,38);
    device3Data.deviceData();
    console.log(device3Data);


});

0 Answers0