Hello Readers,
We developers need to use SP Services a lot in our day to day activities. To save your effort and time, we will see a code st up to get all the details of all items in the list through SP Services which you can use in your respective projects.
Let's see, how can we achieve it.
- Open a page in SharePoint.
- Edit the page
- Add a HTML Form Web part on the page.
- Paste the following code.
On the refresh or on the document.ready function you will receive an alert with all the details of the items in the list by calling SP Services which you can use in your respective functionality.
As per the script, first we are using jquery.SPServices-0.7.2.min.js for reference to SP Services and then we can see from our script how to call in the service.
Script:
-
- < script src = "/SiteAssets/jquery-1.11.2.min.js" > < /script> < script src = "/SiteAssets/jquery.SPServices-0.7.2.min.js"
- type = "text/javascript" > < /script> < script >
-
- $(document).ready(function() {
-
- $().SPServices({
- operation: "GetListItems",
- async: false,
-
- listName: "Test",
- completefunc: function(xData, Status) {
-
- alert(xData.responseText);
- $(xData.responseXML).SPFilterNode("z:row").each(function() {});
- }
- });
- }); < /script>
With (xData.responseText) you will get all the properties of each item on the list which will make your work easier to achieve your functionality.
So just a minute code, paste it and you will have all the details in just a load of the page. Keep Learning!
Cheers!