I'm working on an inherited project, I have a scenario when a function like this is being called from say... 15 different places simultaneously.
var myCall = function () {
var dfd = $.Deferred();
$.ajax({
type: 'POST',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
url: 'xxxxxxx',
data: { },
success: function(response) {
dfd.resolve();
}
});
return dfd.promise();
};
I want the first call to this function to actually go out and get the data, I want the following calls to just get a promise that gets resolved when the first call finishes. I may be missing something fundamental so I thought I'd ask. Do I need to create an array of promises adding a new promise on every call then resolve all of them when the data has been retrieved?