Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have the following code and it does not work. Apparently it's all right. The List name and the URL.

Can anyone help me find the syntax error?

PS: I use Sharepoint Foundation 2010

  operation: 'GetListItems',
  async: false,
  listName: 'MyList_Name',
  webURL: '', 
  CAMLViewFields: '<ViewFields>'+
                    '<FieldRef Name="NamePage" />'+
                    '<FieldRef Name="Date" />'+
                    '<FieldRef Name="Title" />'+
  CAMLQuery: "<Query><OrderBy><FieldRef Name='Date' Ascending='FALSE'></OrderBy></Query>",
  completefunc: function (xData, Status){

    htmlReturn += '<div class="coluns">';

    $(xData.responseXML).SPFilterNode('z:row').each(function() {
        var Title = $(this).attr('ows_Title'),
            Date = $(this).attr('ows_Date'),
            NamePage = $(this).attr('ows_NamePage');

        if(aux <= 6){
            htmlReturn +=  '<ul>'+
                                '<li class="date">'+Date+'</li>'+
                                '<li><a href="'+NamePage+'.aspx">'+Title+'</a></li>'+
    htmlReturn+= '</div>';

    if(htmlReturn != ''){
share|improve this question

1 Answer 1

up vote 4 down vote accepted
CAMLViewFields: '<ViewFields>'+
                '<FieldRef Name="NamePage" />'+
                '<FieldRef Name="Date" />'+
                '<FieldRef Name="Title" />'+

should be

CAMLViewFields: '<ViewFields>'+
                '<FieldRef Name="NamePage" />'+
                '<FieldRef Name="Date" />'+
                '<FieldRef Name="Title" />'+

note the /on the last ViewFields

Also, this

"<Query><OrderBy><FieldRef Name='Date' Ascending='FALSE'></OrderBy></Query>",

should be

"<Query><OrderBy><FieldRef Name='Date' Ascending='FALSE' /></OrderBy></Query>",

note the / after Ascending='FALSE'

share|improve this answer
Thank u.. It worked :D – luanna.iozzi Aug 25 '14 at 13:44
Glad to hear that! – Robert Lindgren Aug 25 '14 at 13:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.