I was trying to generate a line chart connecting to SPList as shown below. But am getting the error undefined here:

alert(' inside completfunc xdata.responsexml is .....'+ xData.responseXML.xml);

The code from where I have taken is http://www.c-sharpcorner.com/UploadFile/313769/display-sharepoint-list-data-in-charts-using-google-api-and/ shows,we can generate charts using the spservices and jquery.

I have created the same splist, with similar columns and but still, when I debugged the code, xData.responseXML.xml populated as "undefined" !
My Title column been renamed as Year. So should I rename it
in the below line also?

      CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef 
      Name='Swift' /><FieldRef Name='Skoda_x0020_Rapid' /></ViewFields>",  

Am stuck at here , why I am getting this issue:

    <script language="javascript"  
          <script language="javascript" 
          0.7.2.min.js" type="text/javascript">
       <script type="text/javascript"  

  <script type="text/javascript">  
  function drawChart() {  

   alert('inside drawchart');
        var SalesData = GetMySalesData();  
        var optionsSalesData   = {  
        title: 'Number of sales',  
        vAxis: {  
                viewWindow: {min: -1},  
                title: "Number of Incidents",  
                displayAnnotations: true  
         hAxis: {  
                title: "Years"                
        pointSize: 5,  

        legend: { position: 'right' }  

        alert('b4 calling chartsales');
        var chartSales = new 
        alert('object exists ');
        chartSales.draw(SalesData, optionsSalesData);     
        alert('drawing completed');

   function  GetMySalesData()  
    alert('get my sales data');
    var data = new google.visualization.DataTable();  
   data.addColumn('string', 'Year');  
   data.addColumn('number', 'Swift');  
   data.addColumn({type: 'string', role: 'annotation'});  
   //data.addColumn('number', 'I 20');  listName: "{E608A64E-F77C-4191-  
     B84F-D41A1CA8FC88}",       data.addColumn({type: 'string', role: 
       data.addColumn('number', 'Skoda Rapid');  
      data.addColumn({type: 'string', role: 'annotation'});  
      alert('b4 calling spservices get list items');

    operation: "GetListItems",  
    async: false,  
    listName: "Sales",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' />
     <FieldRef  Name='Swift' />
    <FieldRef Name='Skoda_x0020_Rapid' /></ViewFields>",  
   CAMLRowLimit: 1,
  completefunc: function (xData, Status) {  
    alert(' inside completfunc xdata.responsexml is .....'+ 
      var itemCount = $(xData.responseXML).find("
    alert("itemCount :" + "" + itemCount);
    var count = 0;  
    count = count + 1;   

    var Year =  $(this).attr("ows_Title");  
    alert(Year + ' is the year');
    var SwiftSalesCount =  $(this).attr("ows_Swift");  
    alert(SwiftSalesCount + ' is the swift sales count');
    var SkodaSalesCount =  $(this).attr("ows_Skoda_x0020_Rapid");  
    alert(SkodaSalesCount + ' is the skoda sales count');
    data.addRow(["'"+ Year +"'", 

    return  data;  
<div id="SalesChart" style="width:300px;height: 300px;float:left 
   ;margin:0 auto;display:block"></div>  
  • 1
    You need to provide the internal name, so you should provide Title in your CAML even though it was renamed to Year. Dec 21 '15 at 13:48
  • I have tried with the internal name also, but the result is same,am getting undefined in responsexml.xml Dec 21 '15 at 13:50
  • Is there any restrictions that, it will work only in SP 2013 ? Am in SP 2010 and am using jquery-1.8.2.min.js & jquery.SPServices-0.7.2.min.js. In the article, they used jquery-1.8.3.min.js. Does this make a big difference? Dec 21 '15 at 13:54
  • in the console, am getting the syntax error : Syntax error, unrecognized expression: [nodeName=rs:data] Dec 21 '15 at 14:21

I found the answer myself, the issue is mentioned Here by Marc.

I should NOT use


instead, have to use


its because the jQuery version 1.8.2 doesn't support nodeName='z:row' so,we must use SPFilterNode("z:row").each(function) in SPServices 0.7.2.

enter image description here



Your errors will not be helpful until you know what you are looking at. When I get xml errors it usually means that I am hitting a web service and getting back html status 400 which is in html and does not have the xml you are expecting.

First step: Get the query going without the arguments. A quick easy way is to just drop the CAMLViewFields argument since it is optional. You won't get everything you need, but you should get back your XML. (but just in case alert with xData.responseXML instead of xData.responseXML.xml)

Add the CAML query. From this point I recommend you grab a CAML editor and simplify your query until you get some xml back. Then, use the editor to build back up until you have what you need.

  • Appreciate the suggestions. Will try on those steps you have mentioned. BTW, shouldn't we use the[nodename= rs:data] ? Because there is another alternative Spfilternode post SPServices 0.7.2 version . Dec 21 '15 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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