我需要在不同位置多次调用的函数是同步的,getItemsCampanha和onQuerySucceeded,例如:
function getItemsCampanha(CAML) {
context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed));
}
$(document).ready(function () {
$('#Div').change(function () {
if ($('#Select').val() == "Value") {
getItemsCampanha(CAML);
alert("2");
}
});
});
function onQuerySucceeded() {
alert("1");
}
function onQueryFailed(sender, args) {
}
我需要提醒尊重数字1,2,但警告2,1。
答案 0 :(得分:0)
我不确定你的目标是什么,但是......
function getItemsCampanha(CAML) {
context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed));
}
$(document).ready(function () {
$('#Div').change(function () {
funToCallAfterQuerySucceeds = function() {
if ($('#Select').val() == "Value") {
getItemsCampanha(CAML);
alert("2");
}
}
});
});
function onQuerySucceeded() {
alert("1");
funToCallAfterQuerySucceeds();
}