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.

SharePoint deveopment training course

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:

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

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →