GetListItems

Function

$().SPServices

Web Service

Lists

Operation

GetListItems

Notes

  • This operation accepts a webURL option. This allows you to change the context for the operation to a different site. Using a GUID for the listName does NOT change the context as it does with the Object Model, so you need to use the webURL option as well if your list is in a different site.

Tips

See Steve Ottenad's post about getting the MetaInfo in a useful way. The trick is to add the following snippet to your call:

CAMLViewFields: "<ViewFields Properties='True' />",

fereko noted that there is a QueryOption which isn't detailed in the SDK and returns account name, email, and name instead of just the name:

CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>"

Example

This is an example from the SharePoint and jQuery forum at Stump the Panel over at http://www.endusersharepoint.com.

In this example, we're grabbing all of the items in the Announcements list and displaying the Titles in a bulleted list in the tasksUL div.

If you have a better, real life example, please create an issue or an PR.

<script type="text/javascript" src="filelink/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="filelink/jquery.SPServices-0.6.2.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).SPFilterNode("z:row").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
        $("#tasksUL").append(liHtml);
      });
    }
  });
});
</script>
<ul id="tasksUL"/>

Back to top