Javascript Push() and value access


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();

    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) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() { 

				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

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.
I think you're missing a parenthesis...try each(function()) and see
IsaacSharePoint Client Side DeveloperAuthor Commented:
I am using jquery not php
Then you maybe have inserted } instead of }); at line 23.
IsaacSharePoint Client Side DeveloperAuthor Commented:
I'm using notepad and all of my braces and parenthesis have their open and close.

Is this right?

What's the proper syntax to get the value of that kind of an array?
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.