I'm using GetListItems with query on SP page called for eg. "A" and everything is working there. Now I copied same code to second list B and in this list xData.responseXML is empty when I'm using CAMLQuery (order by query). But if I'm not using it, response I get is ok.
completefunc: function (xData, Status) {
console.log("is working here")
$(xData.responseXML).SPFilterNode("z:row").each(function() {
console.log("but not working here")
Can you tell me why? Why some CAMLQuery is prventing to get me responseXML? And why its working on diffrent webpage? How it is possible?
EDIT: function added
I'm running it by
getDefaultView()
and the function is:
var getDefaultView = function(search_id){
var list = "Projects"; //list name
var method = "GetListItems";
var fieldsToRead = "<ViewFields>" +
"<FieldRef Name='ID' />" +
"<FieldRef Name='ProjectCode' />" +
"</ViewFields>";
var query = "<OrderBy>" +
"<FieldRef Name='ProjectCode'/>" +
"</OrderBy>";
if(search_id!=undefined){
query = "<Query>" +
"<Where>"+
"<Eq>"+
"<FieldRef Name = 'ID' /><Value Type='Text'>" + search_id +"</Value>"+
"</Eq>"+
"</Where>" +
"</Query>";
}
$().SPServices({
operation: method,
async: false,
listName: list,
CAMLQuery: query, //if commented everything works
CAMLViewFields: fieldsToRead,
completefunc: function (xData, Status) {
console.log(xData); //here the response is displayed properly.
console.log("is executing");
$(xData.responseXML).SPFilterNode("z:row").each(function () {
console.log("is not executing");
});
}
});
};
And summarry:
xData is full of data I asked. Both when using CAMLQuery query,and when not using query.
Code below is executing only when CAMLQuery is commented
$(xData.responseXML).SPFilterNode("z:row").each(function () { console.log("is not executing"); });
EDIT2:
POST message:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>Projects</listName>
<viewName></viewName>
<query>
<Query>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
</query>
<viewFields>
<ViewFields>
<FieldRef Name="ID"></FieldRef>
<FieldRef Name="ProjectCode"></FieldRef>
</ViewFields>
</viewFields>
<rowLimit>0</rowLimit>
<queryOptions>
<QueryOptions></QueryOptions>
</queryOptions>
</GetListItems>
</soap:Body>
</soap:Envelope>
And returned XML:
XML Parsing Error: reference to invalid character number Location: moz-nullprincipal:{c4f4a895-d0bb-45fc-b562-6de85f249fa5} Line Number 11642, Column 225:
...itle='Salesforce effectiveness operations toolkit' tag_ID='11407' tag_Un...
...-------------------------------------------------^