最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

accessing sharepoint list using javascript - Stack Overflow

programmeradmin1浏览0评论

hi How to access sharepoint list from javascript using ajax? I am getting 404 error everytime.

     var d ="<?xml version=\"1.0\" encoding=\"utf-8\<soap:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap=\"/\">
<soap:Body><GetListItems xmlns=\"/\">
<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>";

Can someone check if Soap envelope is correct?

hi How to access sharepoint list from javascript using ajax? I am getting 404 error everytime.

     var d ="<?xml version=\"1.0\" encoding=\"utf-8\<soap:Envelope xmlns:xsi=\"http://www.w3/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap/soap/envelope/\">
<soap:Body><GetListItems xmlns=\"http://schemas.microsoft./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>";

Can someone check if Soap envelope is correct?

Share Improve this question edited Feb 8, 2011 at 18:59 santosh singh 28.7k27 gold badges87 silver badges133 bronze badges asked Feb 8, 2011 at 18:30 Dammanjit RainaDammanjit Raina 211 silver badge3 bronze badges 1
  • Using single quotes (') to enclose that string would save you the trouble of having to escape all the internal quotes. – Marc B Commented Feb 8, 2011 at 19:17
Add a ment  | 

1 Answer 1

Reset to default 4

It would be easyer to use a library instead of forging soap envelopes yourself. Try SPServices, a jQuery library for SharePoint web services.

Then you just do 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>",
    pletefunc: 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"/>

Nice!

发布评论

评论列表(0)

  1. 暂无评论