Newbie's problem with GetListItems and Firefox

Apr 2, 2010 at 7:08 PM

First: Thanks so much for this library - it's been a huge help.  I'm fairly new to it and to jQuery, though, and I must be doing something wrong with the GetListItems operation in $().SPServices.   My code works perfectly in IE, but I'm not getting all the list data back in Firefox.  There is only one item in the list I'm working with, it's used to provide default data for another application.  Using this simple code for testing:

$().SPServices({
  operation: 'GetListItems',
  listName: 'Setup',
  CAMLRowLimit: 1,
  completefunc: function(xData, Status) {
   var out = $().SPServices.SPDebugXMLHttpResult({node: xData.responseXML});
   $('body').append(out);
  } 
 });

I get a full XML response in IE, but in Firefox (and Chrome, for that matter), the listing stops at the <listitems> node.  No <rs:data>, no <z:row>.   What's truly confusing to me is that if I switch operations to GetList or GetListAndView, I get a full response in FF and Chrome.  It only seems to be GetListItems that's not working.  Any help would be greately appreciated (and would result in even more spontaneous praise for this library than I already give, which is a lot).  Thanks!

Coordinator
Apr 2, 2010 at 7:45 PM

Let's try to isolate the problem.  You're calling SPDebugXMLHttpResult, which could also have a bug.  Try this instead:

$().SPServices({
  operation: 'GetListItems',
  listName: 'Setup',
  CAMLRowLimit: 1,
  completefunc: function(xData, Status) {
   alert(xData.responseXML.xml);
  } 
 });

M.

Apr 2, 2010 at 11:33 PM

I tried this, and while it works in IE, xData.responseXML.xml comes up “undefined” in the Firefox alert.   (BTW: I’m using jQuery 1.4.2 and SPServices 5.2.)  I tried a few variations on this, hoping it might narrow things down:

 $().SPServices({
  operation: 'GetListAndView',
  listName: 'Setup',
  completefunc: function(xData, Status) {
   var idAttr=$(xData.responseXML).find('List').attr('ID');
   alert(idAttr);
   alert(xData.responseXML.xml);
  } 
 });

In IE, the first alert shows the correct List ID, and the second shows the entire XML response.  Interestingly, in Firefox, the first alert still shows the correct ID, but he second alert comes up undefined.  For GetListItems, I have trouble using the jQuery “find” function on the SP XML that comes back from that web service, so instead I used this:

 $().SPServices({
  operation: 'GetListItems',
  listName: 'Setup',
  completefunc: function(xData, Status) {
  var zData=xData.responseXML.getElementsByTagName('z:row')[0];
  var attrlist=zData.attributes;
  var attrValue=attrlist[0].text;
  alert(attrValue);
  alert(xData.responseXML.xml);
  } 
 });

In IE, the value from the first column of the first item in the Setup list displays in alert number one, followed by the entire XML set in alert number two.  In Firefox, both alerts show undefined.

Thanks so much for the quick response!

-Jody

Coordinator
Apr 3, 2010 at 2:49 AM
Edited Apr 3, 2010 at 2:49 AM

Jody:

Take a look at this post of mine about working with the namespaces in the returned XML:
http://mdasblog.wordpress.com/2009/11/08/sharepoints-web-services-jquery-and-the-zrow-namespace-in-safari-and-chrome/

I usually do my development with IE and then test the functionality in the other browsers.  I wouldn't worry about the .xml trick not working in Firefax; it's the end result that matters. 

I use GetListItems in quite a few of the functions in the library, so I know that it works, and that it works cross-browser.

M.

Apr 3, 2010 at 3:27 AM

Marc,

That did the trick!  Again, thanks for your amazing work here, and for taking the time to help a noob out.

Have a great weekend.

Best,

Jody

Coordinator
Apr 3, 2010 at 3:33 AM

Excellent! Don't hesitate to ask more questions.

M.