function api() { _self = $(this); setData('parameters', { host: $("#host").val(), aid: $("#aid").val(), uid: 876, token: $("#token").val() }); function getAid() { query ='uid='+getData('parameters').uid; $.ajax({ url: getData('parameters').host+'ajax/album.php', type: "GET", data: query, success: function(response){ getData('parameters').aid = 123; console.log(getData('parameters').aid); //123 } }); } getAid(); function setData(key, data) { _self.data(key, data); } function getData(key) { return _self.data(key); } console.log(getData('parameters').aid); //876 }
Here I am learning to write code using classes on js, please tell me how I can change a variable in success, so that the change would be distributed to the whole class, and not just inside the success function.
There I explained in the comments, I think you understood me.