Read list or document library items using jQuery SPServices in SharePoint 2013

This SharePoint 2013 SPServices tutorial explains, how to read list or document library items using jQuery and SPServices in SharePoint 2013/2016.

We will discuss how we can read list items and document library items using jquery.SPServices.min.js in SharePoint 2013. Here we need to give reference to the jquery.min.js and jquery.SPServices.min.js files. In my case, I put the files inside the Style Library.

Download SPServices library from GitHub

Read List Items using SPServices in SharePoint 2013

Below is the code to read list items from a SharePoint 2013 list using SPServices.

<script type="text/javascript" src="https://Site Coll URL/Style Library/jquery.min.js"> </script>
<script type="text/javascript" src="https://Site Coll URL/Style Library/jquery.SPServices.min.js"> </script>

<script type="text/javascript">
$(document).ready(function() {
var SOStatusreports=[] $().SPServices({
operation: "GetListItems",
async: false,
listName: "Your-List-Name",
CAMLViewFields: "<ViewFields><FieldRef Name=’Title’ /><FieldRef Name=’Attachments’ /><FieldRef Name=’Modified’ /><FieldRef Name=’Link’ /></ViewFields>",
CAMLQueryOptions: "<QueryOptions><IncludeAttachmentUrls>True</IncludeAttachmentUrls></QueryOptions>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function(index) {

SOStatusreports.push($(this).attr("ows_Attachments").replace(';#’,"))
var trimurl= SOStatusreports[index];
itmurl = trimurl.replace(';#’,")
var liHtml = "<li><a href='"+itmurl+"'>" +$(this).attr("ows_Title") + "</a></li>";
$("#MyListItems").append(liHtml);
});
}
});
});
</script>

<ul id="MyListItems"> </ul>

Here it will appear in <li> format in hyperlink and once you click on an item it will open the item details page.

Read Document Library Items using SPServices in SharePoint 2013

Below is the code to read list or library documents from a SharePoint 2013 list.

<script type="text/javascript" src="https://Site Coll URL/Style Library/jquery.min.js"> </script>
<script type="text/javascript" src="https://Site Coll URL/Style Library/jquery.SPServices.min.js"> </script>

<script type="text/javascript">

$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Your-document-library-name",
CAMLViewFields: "<ViewFields><FieldRef Name=’Title’ /><FieldRef Name=’EncodedAbsUrl’/></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var liHtml = "<li><a href="+$(this).attr("ows_EncodedAbsUrl")+">" + $(this).attr("ows_Title") + "</a></li>";
$("#MyDocItems").append(liHtml);
});
}
});
});
</script>

<ul id="MyDocItems"> </ul>

Here it will appear in <li> format in hyperlink and once you click on an item it will open the document.

You may like following SPServices SharePoint 2013/2010 tutorials:

I hope this SPServices SharePoint 2013 tutorial helps to learn how to read list or document library items using jQuery SPServices in SharePoint 2013

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>