javascript - Handling a return value of my jQuery POST in an object constructor -
Hi, I have a problem managing my return to the success of my jQuery post in my Object Constructor, I'm sure the "Return" is not in the right place, but cant find the solution. The Debug Console log shows what looks like in my methods but when I run the code it is not. Thanks for your help in this code
var url = "http://192.168.1.125:8083/ZWaveAPI/Run/"; Function Devices (id, examples, command classes) {this.id = id; This example = example; This.commandClasses = Command Classes; //console.log(this.device); //console.log(this.commandClasses); this. Device update = function () {$. Ajax ({type: "post", url: "" + url + "device [" + + this.id + "]. Example [" + + this.instances + "]. CommandClasses [" ++.com "] +" This.commandClasses + "] Receive () ", success: function (textstats) {console.log (textstats); return text status;}, datatype:" jason "}); }; this. Device data = function () {$. Ajax ({Type: "POST", url: "" + url + "Device [" + + this.id + "]. Example [" + + this.instances + "]. CommandClasses [" ++.com "] Data ", success: function (data) {var dataResponse = {deviceName: data.name, levelValue: data.level.value}; console.log; return data; Response;}, data type:" 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);});