我正在尝试使用 JQuery 从共享点站点获取列表数据,但尚未返回任何内容,firebug 中也没有错误。知道出了什么问题吗?
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(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>Action Items</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
url: "http://my_site/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});
});
function processResult(xData, status) {
$(xData.responseXML).find("z\\:row").each(function() {
console.log("aaaa");
var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
$("#tasksUL").append(liHtml);
});
}
最佳答案
就在您的线路之后
function processResult(xData, status) {
添加这样的警报:
alert(xData.responseText);
这将向您显示调用 GetListItems 所返回的内容。
另外,您应该更改此行:
$(xData.responseXML).find("z\\:row").
对此:
$(xData.responseXML).find("[nodeName='z:row']")
跨浏览器更可靠。 (参见我的博文:http://sympmarc.com/2009/11/08/sharepoints-web-services-jquery-and-the-zrow-namespace-in-safari-and-chrome/)
正如 Rob Windsor 在他的回答中提到的,我已经用 jQuery 封装了许多 SharePoint Web 服务,以使它们在我的 SPServices jQuery library 中更易于使用。 。我建议您尝试一下,因为您不需要做那么多工作。
关于javascript - 使用 Jquery 从 SharePoint 2010 网站获取列表数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6631181/