I have the following code withhn a module
var def = $.Deferred();
$.getJSON("http://localhost:62588/api/Values/getXMLData")
.done(function(json){
def.resolve($.parseJSON(json));
});
return def;
I then have to call it from another module so it completes, before calling a processing the returned data.
repository.getUserPolicies().done(function (userPolicies) {
process(userPolicies);
});
This works well but I don't yet quite understand how the deferred object works yet.
I have read that you can use getJSON's deferred object but not sure if that's exactly what I'm doing here?
I was wondering if there are any disadvantages of this approach?
Can it be done more elegantly?
Thanks