This project has moved and is read-only. For the latest updates, please go here.

Cannot get list items from a Sharepoint list

Sep 13, 2010 at 12:11 PM

I am trying to get the list items with the following code, and although no errors are reported in the browser, nothing is displayed.

The full list url is the following;

- all code put into a content editor webpart.
- jquery and spservices are stored on Sharepoint for easier access.
- the only alert that IS working is the first one in the .ready function.
- the alert in the completefunc is NOT firing.

<script src="/Lists/Site%20Code/Attachments/20/jquery-1.4.2.min.js" type="text/javascript"></script> <script src="/Lists/Site%20Code/Attachments/27/jquery.SPServices-0.5.6.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { alert("This alert is firing!"); $().SPServices({ operation: "GetListItems",   async: false,
  webURL: "/Units/InformationManagement/seanspiteri",
listName: "Test1", CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>", completefunc: function (xData, Status) { $(xData.responseXML).find("z:row").each(function() {
      alert("This alert is NOT firing!");
      $("#output").append($(this).attr("ows_Title") + "<br />"); }); } }); }); </script> <div id="output"></div>

Would appreciate some helpful hints on what might be the problem.

Thanks in advance,


Sep 13, 2010 at 12:22 PM


Add an alert at the top of the completefunc like this:


This will show you the XML result set and will probably help you to debug. The alert you have in the completefunc is within the .each(), so if there are no rows returned (for whatever reason) it won't fire.

Also look at this blog [post of mine for info on the z:row namespace with different browsers:


Sep 13, 2010 at 1:50 PM

Thanks for your quick reply and the debugging hints.

The alert displayed the List XML including the existing 3 items, so the problem is finding the z:row and displaying them.

I have added some more debugging code to the completefunc to try and locate the problem. All are commented, to know what worked and what didn't.

completefunc: function (xData, Status) {

// *** This is working - displaying the XML with 3 items returned.

// *** This is working - appending test to the output div
// *** This is NOT working - nothing happens - tried to get the xml data to copy and paste the result here.
$(xData.responseXML).find("z:row").each(function() { 

// The following 2 lines of code are NOT working either.

 $("#output").append($(this).attr("ows_Title") + "<br />"); }); } });



Sep 13, 2010 at 2:58 PM

I found the culprit! :)

This line was not correct;

$(xData.responseXML).find("z:row").each(function() {

It has to have the double backslashes '\\' like so;

$(xData.responseXML).find("z\\:row").each(function() {

Still I do not know what is the meaning of those backslashes, why are they required? What is their function?

Sep 13, 2010 at 4:25 PM

The first backslash escapes the second, which escapes the colon. ;+)  Read the blog post I posted above for a more reliable method.


Sep 13, 2010 at 5:37 PM

Thought it had something to do with escaping...  but wasn't 100% sure :)

Thanks a lot for your help, probably couldn't have done it otherwise.


Sep 28, 2010 at 12:22 PM


I saw in your other post that you still had questions about how best to get z:row. The post I gave a link to above shows the best method, which is:


This is the most reliable, as it works across every browser I've tested.


Sep 28, 2010 at 12:30 PM

I see... oops... my mistake then... was trying all sorts of combinations except just simply and plainly replacing it as mentioned in the articles linked.

Sometimes things are so obvious!!! LOL :D - must be the stress! hehehe