SP Services - JQuery Getlistitems

Aug 9, 2011 at 1:36 PM
Edited Aug 9, 2011 at 1:48 PM

I am using SP Services - JQuery for one of my applications. Just for exploring I placed the code from the below URL into the content editor webpart and placed it on the page.
 
http://www.endusersharepoint.com/STP/viewtopic.php?f=13&t=937&p=4337#p4337
But it is throwing script errors.
object doesn't support this property or method
Line: 389
Char: 3
Code: 0
It is exactly showing  the error  at the below line. If I am placing alert before this line showing the error. If remove the alert it is not showing any script error.

but not displaying any results.
$().SPServices

Find the code below

 

<script type="text/javascript" src="jquery.SPServices-0.5.4.min.js"></script>
<script type="text/javascript" src="jquery-1.6.2.min.js"></script>

<script language="javascript" type="text/javascript"> 

$(document).ready(function() {

alert('hi')

  $().SPServices({

    operation: "GetListItems",

    async: false,

    listName: "Announcements",

    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",

    completefunc: function (xData, Status) {

      $(xData.responseXML).find("[nodeName=z:row]").each(function() {

        var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";

        $("#tasksUL").append(liHtml);

      }); 

    }

  });

});

</script>

<ul id="tasksUL"/>

 

 My webpart page and the script files are in the same library.


Please suggest.
 
Thank you,

Coordinator
Aug 9, 2011 at 1:48 PM
My guess is that your reference to one or both of the script files is not valid. Check out this blog post:
http://sympmarc.com/2011/07/08/adding-jqueryspservices-to-a-sharepoint-page-step-one-always/

M.
>
Aug 9, 2011 at 3:11 PM

Thank you for your response.

It is working after changing the references. but it is  not displaying the results.

The status is "success" .But if I am putting alert in for loop(each) it is not triggering. 

I am using IE 8.0. The below articles says the issues with safari and chrome.

http://sympmarc.com/2009/11/08/sharepoints-web-services-jquery-and-the-zrow-namespace-in-safari-and-chrome/

<script language="javascript" type="text/javascript">   

    $(document).ready(function() {    

       alert("jQuery"); 
alert($().SPServices.SPGetCurrentSite());

$().SPServices({

    operation: "GetListItems",

    async: false,

    listName: "Announcements",

    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",

completefunc: function (xData, Status)
 {
alert(Status)
      $(xData.responseXML).find("[nodeName=z:row]").each(function()

{
        var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
        $("#tasksUL").append(liHtml);
      });
    }
  });
});
</script>
<ul id="tasksUL"/>

Coordinator
Aug 9, 2011 at 3:15 PM

You're going to need to do some debugging here on your own. GetListItems is the most commonly used Web Service operation, so we know that it works.

If you read the documentation, you'll see that you MUST enclose 'z:row' in single quotes:

.find("[nodeName='z:row']").

M.

Aug 9, 2011 at 7:48 PM
Edited Aug 10, 2011 at 2:58 AM

Hi Marc,

 

I also experienced a similar issue with SPServices not loading. I am pulling out my hair, what I have left of it. I have tried every thing I know and now at I'm at a loss. I am using SP 2010. I added the script reference to jquery and spservices before the head tag of my v4 master. Both scripts are in a document library, same site. I have right clicked on both JQ and SPS to copy short cut. This gives me the absolute URL. I can get the alert for JQ when page loads, but nothing for SPS. When I view page source I can see the scripts references, so they are loaded from the master page.

Is there anything else I can try?

thanks a bunch 

Coordinator
Aug 10, 2011 at 12:32 PM

jaxkookie:

In SPD, open the master page and Crtl-Click the src for the SPServices script reference. If it opens, then your reference is good.

M.