Trying to fetch all list items from a list located in a different site collection and traverse the list items, reading some of their column values.
I've taken some code from an example snippet that claims to work just fine (at least in Firefox)
However I seems like xData.responseXML doesn't work as expected.
I never get further than the line $(xData.responseXML).find("z\\:row").each(function(){ - seems like find() fails to find anything, so there are no items avaliable to traverse.
function GetTasks(siteCollection) {
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>Tasks</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
$.ajax({
url: "http://" + siteCollection + "/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
contentType: "text/xml; charset=\"utf-8\"",
complete: function(xData, status){
$(xData.responseXML).find("z\\:row").each(function(){
var title = $(this).attr("ows_FileLeafRef").split("#")[1];
alert(title);
})
},
error: function(){
alert("error");
}
});
}
I've examined the xData.responseXML object and can't seem to find any list items or any property called z:row, however I'm quite confused how this object is structured so not sure where to look..
However I've noticed that xData.responseText contains a string with all the list items I've been trying to fetch.
Example of how an item is formatted
<z:row ows_Title='myTitle1' ows_MetaInfo='1;#' ows__ModerationStatus='0' ows__Level='1' ows_ID='1' ows_UniqueId='1;#{1DDABC4E-C52B-4B81-B65F-50F3381B87EB}' ows_owshiddenversion='1' ows_FSObjType='1;#0' ows_Created='2012-03-12 10:59:04' ows_PermMask='0x7fffffffffffffff' ows_Modified='2012-03-12 10:59:04' ows_FileRef='1;#Lists/Tasks/1_.000' />
However I can't seem to find anything similar within xData.responseXML and I would prefer to work with XML.