更新时间:2023-02-16 22:20:08
paru,
建议您使用Ajax调用REST API通过设置参数["async":false]同步检索列表项.
You can refer to: https://sharepoint.stackexchange.com/questions/208020/make-caml-query-with-in-rest-api-call
您的代码如下所示:
var viewXml = {
ViewXml: "<View><Query><Where><Eq><FieldRef Name=\'Country\' /><Value Type=\'Choice\'>" + country + "</Value></Eq></Where></Query>" +
"<RowLimit>100</RowLimit></View>"
}
var call =
.ajax({url:_spPageContextInfo.webAbsoluteUrl +``/_api/Web/Lists/getByTitle('xyz')/GetItems(query = @ v1)?'' +"@ v1 =" + JSON.stringify(viewXml), 类型:"POST", dataType:"json", 标头:{ 接受:"application/json; odata = verbose", "X-RequestDigest":
.ajax({url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/getByTitle('xyz')/GetItems(query=@v1)?" +"@v1=" + JSON.stringify(viewXml), type: "POST", dataType: "json", headers: { Accept: "application/json;odata=verbose", "X-RequestDigest":
("#__ REQUESTDIGEST").val() }, 异步:假 });
("#__REQUESTDIGEST").val() }, async: false });
有关REST API的更多信息,供您参考. /span>
More information about REST API for your reference.
如果您想使用JSOM来解决问题,您可以参考下面的文章.
***的问候,
Lee Liu