我有3张照片。我尝试通过 caml 查询获取列表项,但它显示错误框。函数 getListItems 可以很好地返回 caml 查询,但函数 GetListItemsByView 不起作用。这是共享点获取列表项应该在不同的网站集中工作。请有人帮忙!!!!!!
最佳答案
修改 GetListitemsByView 函数如下。
function GetListitemsByView(webAppUrl,LibraryName,Text_CAML_Query){
var viewXml = '<View><Query>' + Text_CAML_Query + '</Query></View>';
var queryPayload = {
'query' : {
'__metadata': { 'type': 'SP.CamlQuery' },
'ViewXml' : viewXml
}
};
$.ajax({
url: webAppUrl + "/_api/web/lists/getbytitle('" + LibraryName + "')/getitems",
type: "POST",
data: JSON.stringify(queryPayload),
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"Content-Type": "application/json; odata=verbose"
},
success: function (data) {
$.each(data.d.results,function(i,item){
$("#a").append("<li><div>"+item.Title+"</div></li>");
});
},
error: function (data) {
alert(JSON.stringify(data));
}
});
}
关于javascript - 使用 caml 查询获取列表项剩余调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59055796/