我想加載到一個無序列表的SharePoint列表,所以我可以創建一個簡單的搜索功能(Sharepoint搜索只是可怕的)。我借和適應的代碼如下:使用SharePoint SOAP與jQuery GetListItems - 簡單但不能解決!
$(document).ready(function() {
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>Metric_Audit</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='ReportName' /> \
<FieldRef Name='Metric Name' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
url: "http://teamspace.intranet.group/sites/CSI/ID/DB/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: Result,
contentType: "text/xml; charset=\"utf-8\""
});
});
function Result(xData, status) {
$(xData.responseXML).find("z\\:row").each(function() {
var liHtml = "<li>" + $(this).attr("ows_ReportName") + "</li>";
$("#MetricsUL").append(liHtml);
});
}
});
<ul id="MetricsUL"/>
它填充列表,因爲它應該,但所有項目的名稱爲「未定義」。我試圖刪除空格等無濟於事,當我將列表更改爲「任務」列表,它的工作原理很好。
一直盯着AGES。任何建議,你可以建議將非常感激!我敢肯定,這是一件小事,我只是不能解決問題!
謝謝!
這個問題實際上救了我幾天的工作謝謝。 – 2011-05-19 21:43:46