Can someone help me with this script :)

May 1, 2012 at 7:30 AM

Hi All,
    Can someone help me why i can't print out the title.
I can see the output when i print it out to the screen using :

alert(xData.responseText);

 

See below;

 

$(document).ready(function(){
 listSiteURL = 'http://myserver/sites/Intranet/';

   $().SPServices({
   operation: "GetListItems",
   webURL: listSiteURL,
   async: false,
   listName: "QuickLaunch",
   CAMLQuery: "<Query/>",
   CAMLViewFields: "<ViewFields><FieldRef Name='URL'/></ViewFields>",
 
      completefunc: function (xData, Status) {
       alert(xData.responseText);
  

      $(xData.responseXML).find("[nodeName=z:row]").each(function() {
      
        var title = $(this).attr("ows_URL");
   
         
       alert(title);
   
      });
      

    }
   
  });

  });

Thanks in Advance

 

Coordinator
May 1, 2012 at 12:19 PM

If you're not getting the title alert, then my guess is that you are using jQuery 1.7+. If so, the .find("[nodeName=z:row]") selector won't work; use SPFilterNode instead. See Important Notes on the home page.

M.

May 1, 2012 at 12:43 PM

The solution really depends on the version of jQuery & SPServices you are using.  I believe 1.5+ the jQuery team started to enforce the "quote" rule.

Here's an example, notice the single quotes that surround z:row.

      $(xData.responseXML).find("[nodeName='z:row']").each(function() {
      
        var title = $(this).attr("ows_URL");
   
         
       alert(title);
   
      });
      

I'm thinking that's all you have to do to fix your code, but if that doesn't work, you'll need to post more information about the version of jQuery/SPServices you are using.

 

Cheers,

Matt

May 2, 2012 at 12:27 AM

Will check the quotes out.
The versions 'm using is:

jquery.SPServices-0.6.2.min.js
jquery-1.6.2.min.js

 

Cheers

May 2, 2012 at 12:41 AM

thanks guys very much it was the quote :(
I have been using SPServices alot as i'm addicted to it :) no ideas how i missed that must have copied it from an old source.
Cheers

May 2, 2012 at 12:28 PM

You should consider upgrading though.  Marc has made significant improvements in the latest release.  It's nothing but awesomesauce...