Posted on 2012-08-23
Last Modified: 2012-10-10
I was playing familiarizing myself with SPSERVICES by following the example on the following blog..

I did everything exactly how it was done on the blog but, it does not work for me.  I don't get any errors either.  I added a couple of alert()'s and those poped up but nothing else.

Any ideas?

Attached is my code.
Question by:Isaac
    LVL 44

    Expert Comment

    by:Rainer Jeschor
    you did not mention your SharePoint version but using SiteAsset library I assume SharePoint 2010.
    Attached a modified version of your script.
    I uploaded the complete script as TEXT file to the site asset library and added a content editor web part on a new page, configuring this text file as link source.
    This one works on my machine ;-)

    Main change:
    1. Instead of document ready use the built in container / array _spBodyOnLoadFunctionNames (which will be executed internally on document ready function by function)
    2. Instead of $ use jQuery to avoid conflicts

    You would have to rename the list back - on my system the list is named EESpeakers.
    And adjust the script src links.

    LVL 5

    Author Comment

    I made the changes but it still does not work for me.  I don't get any errors either and my alerts go off.

    Could it be because I'm in Office 365 SharePoint Online?
    LVL 5

    Author Comment

    I'm definiteley doing something wrong.  I added it to another server and same thing.
    LVL 5

    Author Comment

    Here's the code I'm using....

    <script type="text/javascript" src="../SiteAssets/jquery.js"></script>
    <script type="text/javascript" src="../SiteAssets/jquery.SPServices.min.js"></script>
    <script type="text/javascript">
    //this is where the script starts after the page is loaded
    function GetSpeakers()
    	alert("in getspeaker function");
            //The Web Service method we are calling, to read list items we use 'GetListItems'
            var method = "GetListItems";
            //The display name of the list we are reading data from
            var list = "Speakers";
            var fieldsToRead =     "<ViewFields>" +
                                    "<FieldRef Name='Title' />" +
                                    "<FieldRef Name='Blog' />" +
                                    "<FieldRef Name='Picture' />" +
            var query = "<Query>" +
                            "<Where>" +
                                "<Neq>" +
                                    "<FieldRef Name='ID'/><Value Type='Number'>0</Value>" + 
                                "</Neq>" +
                            "</Where>" +
                            "<OrderBy>" + 
                                "<FieldRef Name='Title'/>" +
                            "</OrderBy>" +
            //Here is our SPServices Call where we pass in the variables that we set above
                    operation: method,
                    async: false,  //if you set this to true, you may get faster performance, but your order may not be accurate.
                    listName: list,
                    CAMLViewFields: fieldsToRead,
                      CAMLQuery: query,
                          //this basically means "do the following code when the call is complete"
                        completefunc: function (xData, Status) { 
                            //this code iterates through every row of data returned from the web service call
                            $(xData.responseXML).SPFilterNode("z:row").each(function() { 
                                //here is where we are reading the field values and putting them in JavaScript variables
                                //notice that when we read a field value there is an "ows_" in front of the internal field name.
                                //this is a SharePoint Web Service quirk that you need to keep in mind. 
                                //so to read a field it is ALWAYS $(this).attr("ows_<internal field name>");
                                //get the title field (Speaker's Name)
                                var name = ($(this).attr("ows_Title"));
                                //get the blog url, SharePoint stores a url in the form of <url><comma><description>
                                //We only want the <url>. To accomplish this we use the javascript "split" function
                                //which will turn <url><comma><description> into an array where the first element [0]
                                //is the url.   Catch all that? if you didn't this is another reason you should be
                                //a developer if you are writing JavaScript and jQuery :)
                                var blog = ($(this).attr("ows_Blog")).split(",")[0];
                                //same thing as the blog, a picture is stored as <url><comma><alt text>
                                var pictureUrl = ($(this).attr("ows_Picture")).split(",")[0];
                                //call a function to add the data from the row to a table on the screen
    function AddRowToTable(name,blog,pictureUrl)
        jQuery("#speakerTable").append("<tr align='middle'>" + 
                                    "<td><img src='" + pictureUrl + "'><br><a href='" + blog + "'>" + name + "</a></td>" +
    <!-- table where our speaker rows will go -->
    <table id="speakerTable"></table>

    Open in new window

    LVL 44

    Accepted Solution


    you would have to debug this - in regards to SharePoint online it would probably by an authentication issue - the web service should exist.

    To debug:
    1. Alert the response
    Between line 43 and 44 add an

    2. Use Fiddler
    Use Fiddler ( as proxy and capture the request. You should now see
    - what is the response status (200=OK or 404 not found or 401 not authorized)
    - what is the response content

    - Which jQuery version do you use?
    - Which SPService version do you use?
    - Do it have to be SPService or would the SharePoint Client object model be an alternative?

    Thanks and KR
    LVL 5

    Author Comment

    I get the error,

    'xData' is undefined.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now