access callback response data from Ajax using Javascript Revealing Prototype Pattern -


i trying structurise js code using revealing prototype pattern.

my basic usecase is: create different types of entities person, technology. each entity has own tags. in order these tags make ajax call returns object of tags. want access object in implementation. not sure how in right way.

my attempt follows:

var entity= function (url) {     this.url = url; /*variable can shared instances*/     var entitytags;  };  entity.prototype = function () {     var create = function (type, values) {     //code creating }  var update = function (type, values) {}  var tags = function () {     ajaxcall(' ', this.url, {data:data}, 'callbackaftergettags', '');     callbackaftergettags=function(responsefromajax)     {         entitytags=responsefromajax.tagsreturned; //how access entitytags in implementation     } }; return {      createentity: create,      gettagsentity: tags }; 

my implementation

var myentity = new entity(url); myentity.gettagsentity(); 

ajax call returns object not sure how access object inside tags functions in right way. suggestions? first trial use oo style in js. let me know if right track or not.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -