Newbie - GetListItems - undefined

Sep 29, 2014 at 3:43 PM
Hi! I'm just getting started with SharePoint and SPServices. I've been trying really hard (I promise), but I just can't get this simple code to work. I am trying to populate a select with values from a different list. When I alert the xData.responseText I see XML data with all the fields names and values from the list, but I get 'undefined' on the xData.responseXML.xml. The Status is success. I've verified that the columns name is Title (checked in URL of Column settings). I'm on SharePoint 2013, and on a custom application page and querying a custom list.

Any help would be greatly appreciated!

Thanks,
Eirik

$().SPServices({
operation: "GetListItems",
async: false,
listName: "Research Programmes",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
alert(xData.responseText);
alert(Status + " " + xData.responseXML.xml);
if (Status == "success") {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
$("#selectProjectProgrammeTitle").append("<option value='" + $(this).attr("ows_Title") + "</option>")
});
}
}
});
Sep 29, 2014 at 5:57 PM
You're really close. The XML is there but I don't think it's simply to be referenced as xData.responseXML. You won't need that alert anyway.
In your completefunc, you're missing an apostrophe and a greater than symbol to close out the value of the option so the tag is left open with an unterminated string to boot. Also, you're not including any display text for the option between the opening and closing tags. Try this...
$("#selectProjectProgrammeTitle").append("<option value='" + $(this).attr("ows_Title") + "'>" + $(this).attr("ows_Title") + "</option>") ;
Geoff
Marked as answer by eggij on 9/29/2014 at 11:07 AM
Sep 29, 2014 at 6:07 PM
Wow! You did it! Thanks a lot! You're right, the responseXML gives undefined even so. Now I got this working, I had 100% coding blindness, I didn't see that obvious mistake... Shame shame shame...

Thanks again,
Eirik