I basically need to perform a GetListItems from a SharePoint list on a different server. I have tried different codes but they all error out. Can someone look at what I have and see if it's wrong or if it's just not possible? I get the Error alert then an xData.ResponseText alert as 'undefined'. Nothing after that. The server where I'm running the code is server3.intranet.com. Thank you.
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>Shared Documents</listName> \
<viewFields> \
<ViewFields> \
<FieldRef Name='Title' /> \
</ViewFields> \
</viewFields> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";
function Result(xData, status) {
alert(xData.responseText);
$(xData.responseXML).find("z\\:row").each(function() {
var title = $(this).attr("ows_Title");
alert(title);
});
}
$.ajax({
url: "http://teams02.intranet.com/sites/MySite/_vti_bin/Lists.asmx",
type: "POST",
dataType: "JSONP",
crossDomain: true,
data: soapEnv,
complete: Result,
contentType: "text/xml; charset=\"utf-8\"",
error:function(){
alert("Error");
}
So is there anything that needs to be changed in this code? And is the url that I'm using correct? I'm not sure exactly what I should be pointing this at–if it's the list itself or some sort of virtual path.
Best Answer
Here is a working example: