gpt4 book ai didi

javascript - 如何使用 SOAP 从 Sharepoint List 接收 GetListItems?

转载 作者:行者123 更新时间:2023-11-28 08:22:02 25 4
gpt4 key购买 nike

我需要从 SharePoint 列表中获取列表项。

我是在本地做的。我尝试过使用此代码:

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>

$(document).ready(function() {
var listName = "Backlog";
makeSoapCall(listName);
});

function makeSoapCall(listName){
var soapEnv =
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
<soap:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>" + listName + "</listName> \
<viewName></viewName> \
<query></query> \
<viewFields></viewFields> \
<rowLimit></rowLimit> \
<queryOptions></queryOptions> \
<webID></webID> \
</GetListItems> \
</soap:Body> \
</soap:Envelope>"

$.ajax({
url: "http://server/site/_vti_bin/Lists.asmx",
type: "POST",
dataType: "jsonp",
data: soapEnv,
complete: resultsFeedback,
contentType: "application/json; charset=\"utf-8\""
});

}

function resultsFeedback(xData, status) {
console.log("xData: " + xData);
console.log("status: " + status);
}

然后,我收到了这条消息:

Resource interpreted as Script but transferred with MIME type text/html: "http://server/site/_vti_bin/Lists.asmx?callback=jQuery11100353987290…stItems%3E%20%20%20%3C/soap:Body%3E%20%3C/soap:Envelope%3E&_=1396538736189". jquery-1.11.0.min.js:4 Uncaught SyntaxError: Unexpected token < Lists.asmx:3

xData: [object Object] report.html:37
status: parsererror

有人可以帮忙吗?

提前致谢。埃德森·马丁斯

最佳答案

您的ajax调用对象的数据类型属性不正确。它应该是“xml”。另外,您的“contentType”属性应该具有 application/xml 值而不是 json。试试这个:

$.ajax({
url: "http://server/site/_vti_bin/Lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: resultsFeedback,
contentType: "application/xml; charset=\"utf-8\""
});

关于javascript - 如何使用 SOAP 从 Sharepoint List 接收 GetListItems?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22842318/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com