SPServices Simple HTML/JS Implementation Returns Error

Jan 29, 2013 at 7:38 AM
Edited Jan 29, 2013 at 7:39 AM

I was looking for something like SPServices for Dummies or SPServices Getting Started tutorials but nothing very useful for starters like me. This is my first time to develop with Sharepoint and SPServices, hope you could help me. I'm trying to get a list of "People" from our sharepoint with this very HTML/JS simple code but the status keeps on returning error. Can you tell me what's wrong with my code? Also if you have references on SPServices for newbies, I'd appreciate it a lot if you could share them. Thanks!
<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
 	<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.1a/jquery.SPServices-0.7.1a.min.js"></script>
        <script>

          $(document).ready(function(){
               $().SPServices({
					operation: "GetList",
					listName: "People",
					webURL: "https://nibc.sharepoint.com/sites/BCP/Current/_vti_bin/Lists.asmx",
					completefunc: function (xData, Status) {
						alert(Status);
						console.log(xData);
					}
				});
          });
        
        </script>


      <title>Test SPServices</title>
    </head>
    <body>
        Test
    </body>
</html>

Jan 29, 2013 at 8:21 AM

Hi,

Please make sure that the page below has an entry for "People" and report the exact error you are getting in the response.

https://nibc.sharepoint.com/sites/BCP/Current/_layouts/viewlsts.aspx 
Jan 29, 2013 at 8:22 AM
Edited Jan 29, 2013 at 8:24 AM

To get actual 'people' from an existing list named 'People' you'd need the 'GetListItems' operation rather than 'GetList'.

Coordinator
Jan 30, 2013 at 3:26 AM

haifabaluyos:

The basic instructions are at the bottom of the main documentation page, and each function and Web Services has pretty thorough documentation as well.

You've said that you're getting an error, but not what the error is. acrush is right, though, that you are calling the wrong operation, which should be GetListItems. The webURL is also wrong, as you are pointing to the asmx Web Service rather than the specific Web which contains the list. You only need to specify the webURL if the list is not in the current site.

I think you need something *like*:

$(document).ready(function(){
  $().SPServices({
    operation: "GetListItems",
    listName: "People",
    webURL: "/BCP/Current",
    completefunc: function (xData, Status) {
      alert(Status);
      console.log(xData);
    }
  });
});

Take a read through the documentation and let us know if you have further questions.

M.