Javascript Push() and value access

Hi,

Can someone check and see if the following javascript is correct?  I am trying to push values from a sharepoint list into a multidimensional array but I think I might be doing something wrong when I try to access.  I get an error due to the .each() and when I take it out, the error goes away.  The error says I'm missing a ")"

var anArray = new Array();


$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Analyst",
	CAMLViewFields: "<ViewFields><FieldRef Name='Title'></FieldRef></ViewFields>",
	CAMLQuery: "<Query><OrderBy><FieldRef Name='Title' /></OrderBy></Query>",
    completefunc: function (xData, Status) {
	//alert(xData.responseXML.xml);
      $(xData.responseXML).SPFilterNode("z:row").each(function() { 


			anArray.push({
				Analyst: $(this).attr("ows_Title"),
				Count:	 0
				});			
				


      });
     }
  }); 


   //Am I accessing the values to my array correctly
   $.each(anArray, function (index, value) {																													
        dataAn.addRow([anArray[index].Analyst, Number(anArray[index].Count]));
    }); 

Open in new window

LVL 5
IsaacSharePoint Client Side DeveloperAsked:
Who is Participating?
 
Sar1973Connect With a Mentor Commented:
anArray[x] is the right syntax to get the x-element of the array, while anArray.length will return the number of elements in the array.
0
 
Sar1973Commented:
I think you're missing a parenthesis...try each(function()) and see http://www.w3schools.com/Php/func_array_each.asp
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
I am using jquery not php
0
 
Sar1973Commented:
Then you maybe have inserted } instead of }); at line 23.
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
I'm using notepad and all of my braces and parenthesis have their open and close.

Is this right?
alert(anArray[x].Count);

What's the proper syntax to get the value of that kind of an array?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.