I have a loop where I'm making an ajax post. I want to execute the function "doSomething()" only after my loop (and the ajax posts inside each loop) are complete.
I'm thinking this is called a promise, but I'm just getting into jQuery after doing server side forever...
selectedRows.each(function(e) {
var dataforpost = { groupId: selectedGroup.Id,
userName: userName, displayName: displayName };
$.ajax({
url: '@Url.Action("AddMemberToGroup")',
type: "POST",
data: dataforpost,
success: function(data) {}
});
});
// now when that loop is done, do something
doSomething();