I have something like this:
var MyModule = function() {
// some private var
var myVar1, myVar2;
// some private function
var _myPrivateFunc = function() {
//something
}
// public API
retu {
publicFunction: function(options) {
//something public here
}
}
};
var someOptions = {...};
// create MyModule instance
var test1 = new MyModule();
test1.publicFunction(someOptions);
My goal is to obtain same structure but instead of directly creating an instance of MyModule, I'd like to instantiate the object (test1) after an ajax call. Something like this:
// public API
retu {
publicFunction: function(options) {
$.ajax({
url: options.someUrl,
type: 'POST',
data: options.someData,
datatype: 'json',
success: function(data) {
//here I want to create an instance of MyModule
//with 'data' response object
}
});
}
}
Any kind of solution is accepted but remember to maintain this structure:
// create MyModule instance (wait for ajax response)
var test1 = new MyModule();
test1.publicFunction(someOptions);
That's mean I can't use the callback to obtain data and then instantiate the object.
Thanks
