I want executeQueryAsync to complete before giving back control to webEnumerator.moveNext, anyway ?
function onGetSubwebsSuccess(sender, args) {
var webEnumerator = webCollection.getEnumerator();
while (webEnumerator.moveNext()) {
alert("Loop 1");
web = webEnumerator.get_current();
this.props = web.get_allProperties();
context.load(this.props);
context.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));
}
}
function gotProperty() {
var myPropBag = this.props;
alert("Loop 2");
}
What's happening now is, I get alert for "Loop 1" twice and then alert for "Loop 2" when it should be like this,
Loop 1
Loop 2
Loop 1
Loop 2
See Question&Answers more detail:os