Dinesh Dinesh - 1 month ago 16
HTML Question

Accessing Sharepoint list data in a normal HTML page using JavaScript

I am trying to create a simple HTML page where i wanted to display a list of items from a SharePoint list. Basically my JavaScript has to pull the data from SharePoint list and display in HTML page.

I have tried some sample from internet, nothing worked. Can anybody have any samples on this. Please help me to implement this.

vvk vvk
Answer

You can use jQuery Library for Sharepoint WebService

<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"/>