我从共享点列表中获取信息,然后我想使用该数据。问题是我需要在使用 Sharepoint 服务器之前更新数据,但我无法让 executeQuery() 工作。我可以让 executeQueryAsync() 工作。这是我的代码:
// Global variables;
var context;
var web;
var list;
var howManyItem = 0;
var allItems;
var randNums = [];
// Initializes the variables; Sets listname; Gets all items;
function init(){
context = new SP.ClientContext.get_current();
web = context.get_web();
// Enter the list name;
this.list = web.get_lists().getByTitle('LetsTalkAdded');
// Get item count in the query/list;
var query = SP.CamlQuery.createAllItemsQuery();
allItems = list.getItems(query);
context.load(allItems, 'Include(Title)');
context.executeQueryAsync(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));
}
这很好用,但是当我将最后一行更改为:
context.executeQuery(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));
它不再起作用,但我不能异步运行它们。如果我这样做了,那么依赖于该信息的代码部分将不起作用。为什么 executeQuery() 函数不起作用?