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

GetListItems returns undefined in Google Chrome

Jul 7, 2011 at 9:07 PM
Edited Jul 7, 2011 at 9:12 PM

SPServices is a great library that has been helpful in solving many of my problems except just this one.


var camlQuery = "<Query><Where><And><Eq><FieldRef Name='Author' /><Value Type='User'>" + userID + 
"</Value></Eq><Eq><FieldRef Name='Status' /><Value Type='Text'>Started</Value></Eq></And></Where></Query>";
	operation: "GetListItems",
	async: false,
	listName: "My Tasks",
	CAMLQuery: camlQuery,
	completefunc: function (xData, Status) {
			taskID = $(this).attr("ows_ID");
			start = $(this).attr("ows_Start");
			end = $(this).attr("ows_End");
			hours = $(this).attr("ows_Hours");


This works without a hitch in IE9 but it chokes in Chrome.  The alert pops up with "undefined" instead of the expected XML.  Is there a workaround to this?

Jul 7, 2011 at 9:33 PM

Small update.

I replaced alert(xData.responseXML.xml) with alert(xData.responseText) and Chrome is able to pop up the data.  I suppose I could parse the text result to get to the values instead of using z:row, but why does Chrome not want to work with the XML?

Jul 7, 2011 at 10:18 PM

What versions of jQuery and SPServices are you running?

Jul 7, 2011 at 10:28 PM



Jul 7, 2011 at 10:41 PM
Edited Jul 7, 2011 at 10:46 PM

Nevermind I retract my statement in the post above.  Chrome does not pop up the list items in text nor XML format, thus there is nothing for me to parse.  In fact, the entire GetListItems and CAML query operation fails to retrieve anything at all when using Chrome.

I also tried an alert(Status) popup.  Both IE and Chrome display success...

Jul 7, 2011 at 10:48 PM

If you're getting "Success" back in the Status in Chrome, then there ought to be *something* when you alert(xData.responseText). An error?


Jul 7, 2011 at 11:04 PM
Edited Jul 7, 2011 at 11:05 PM

Nvm again, you're right Marc.  It does return the full text with the list items.  I'm just out of it this afternoon.

Now, this may be turning into a whole different problem.  So based on the items returned from the GetListItems operation, I need to enable an ASP.NET button from a disabled state.  I'm using $('.startTimer').attr("disabled", ""), where startTimer is the CssClass attribute for the button.  This works fine in IE, but not in Chrome.

Jul 7, 2011 at 11:18 PM

Ok I figured everything out and it works with Chrome, yay!  With jQuery version 1.6+, the correct syntax is $('.startTimer').attr("disabled", true) or $('.startTimer').attr("disabled", false).

For the benefit of anyone else who encounters this problem, here is my solution below

completefunc: function (xData, Status) {
	// This is a workaround to the cross browser compatibility problem with XML.  Parse the text result instead.
	data = xData.responseText;

	start = data.slice(data.indexOf("ows_Start='"));
	start = start.slice(start.indexOf("'") + 1);
	start = start.slice(0, start.indexOf("'"));
	end = data.slice(data.indexOf("ows_End='"));
	end = end.slice(end.indexOf("'") + 1);
	end = end.slice(0, end.indexOf("'"));
	hours = data.slice(data.indexOf("ows_Hours='"));
	hours = hours.slice(hours.indexOf("'") + 1);
	hours = hours.slice(0, hours.indexOf("'"));
	// Clean up 'hours' variable
	hours = hours.slice(hours.indexOf("#") + 1);	

Thanks iOnline247 and Marc for your responses as they guided me to the solution!

Marc, it'd still be nice if I could use the z:row function instead of manually parsing text  :)

Jul 8, 2011 at 12:46 AM

You should be able to do things the "normal" way with z:row in Chrome. I know Matt uses Chrome as his primary browser, so maybe he'll have some insights.


Feb 12, 2014 at 6:08 PM

we can still use xData.responseXML by converting xData.responseText to xml format with below steps.

var test = xData.responseText,
data = $.parseXML(test),
$test = $(data);

    date=new Date($j(this).attr("ows_EventDate").substring(0,4),
Feb 12, 2014 at 7:23 PM
You shouldn't need to do this in Chrome.