JSOM - 在一个请求中加载多个SharePoint对象

时间:2017-10-13 16:39:55

标签: sharepoint sharepoint-2010 sharepoint-jsom

有没有办法在一个请求中加载多个对象,如下所示:

var context = new SP.ClientContext.get_current();
                    this.web = context.get_web();
                    this.site = context.get_site();
                    var list = this.web.get_lists().getByTitle(window.sessionStorage.getItem('selectedContentType'));
                    var query = '<View Scope=\'RecursiveAll\'><Query>' + $('.camlQuery').val() + '</Query></View>';
                    var camlQuery = new SP.CamlQuery();
                    camlQuery.set_viewXml(query);
                    this.items = list.getItems(camlQuery);
                    context.load(this.site);
                    context.load(this.items, 'Include(ID,DocIcon,LinkFilename,FileRef,FileLeafRef,Title,ContentType,SupplierPGProduct)');
                    context.executeQueryAsync(Function.createDelegate(this, get_Data_onSuccess), Function.createDelegate(this, get_Data_onFailure));
                }

在此示例中,我指的是一个异步请求中的this.sitethis.items? 或者我必须先加载this.site并在请求成功时加载this.items

1 个答案:

答案 0 :(得分:0)

我在sharepoint.stackexchange中找到了答案。 这是答案的链接。

https://sharepoint.stackexchange.com/a/227984/47825