SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.