喜 如何使用ajax从javascript访问sharepoint列表? 我每次都会收到404错误。
var d ="<?xml version=\"1.0\" encoding=\"utf-8\<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>TEST</listName>
<queryOptions></queryOptions>
<query><Query><Where><Eq><FieldRef Name=\"Title\"/><Value Type=\"Text\">title</Value></Eq></Where></Query></query>
</GetListItems>
</soap:Body></soap:Envelope>";
有人可以检查肥皂信封是否正确吗?
答案 0 :(得分:4)
使用库而不是自己伪造肥皂信封会更容易。试试SPServices,一个用于SharePoint Web服务的jQuery库。
然后你做something like:
<script type="text/javascript" src="filelink/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="filelink/jquery.SPServices-0.5.4.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Announcements",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).find("[nodeName='z:row']").each(function() {
var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
$("#tasksUL").append(liHtml);
});
}
});
});
</script>
<ul id="tasksUL"/>
尼斯!