title: assign object to array in javascript multidimensional array
body: <p>Below i have given my code which is a javascript function which calls a php file and gets json data .... all things are perfect yet but i am getting problem when i want to adda data to a multidimensional array .. sorry for this noob question.. i don't know it can be done or not.</p>
  
  <p><strong>what i want to do</strong></p>
  
  <ol>
  <li>i want to retrieve data on ajax call and save this data to array </li>
  <li>so i dont need to call again if i need data again</li>
  <li>so i want to store data in multidimensional array which will have two keys</li>
  <li>first key will be length iof array </li>
  <li>and second will be dataType of my data which can be "name", "id", "description"</li>
  <li>is this right way to do this </li>
  <li>if it is not then what should i try ...? HELP ME...!!!</li>
  <li>or can i assign full jsondata object data got from ajax call success to an array </li>
  </ol>
  
  <p><strong>Newly added requirements of my question</strong>
  Its associative array like my php array of data is like</p>
  
  <pre><code>$data[0]["id"] = 1;
  $data[0]["name"] = "spomething";
  $data[0]["descriptoon"] = "spomething";
  $data[0]["image"] = "spomething";
  
  //for second item
  $data[1]["id"] = 1;
  $data[1]["name"] = "spomething";
  $data[1]["descriptoon"] = "spomething";
  $data[1]["image"] = "spomething";
  </code></pre>
  
  <p>so i want to create same array for javascript... for every item i fetch... from ajax../ and include into javascript array...  </p>
  
  <pre><code>    $('.searchButton').bind("mouseover", function() {
  
          var data = $(this).parents('.item').attr('id');   
          var type = $(this).parents('.tab-pane').attr('id'); 
          // dataArray will be global javascript variable because of its needdss... it will be outside the function
          var dataArray = new Array();
  
          $.ajax({
              type: 'GET',
              url: '&lt;?php echo $this-&gt;createUrl("dining/AjaxItemDetailsCall") ?&gt;/data/'+data,
              dataType: 'json',
              async: false,
              success: function(data){  
                  var dataArrayLength = dataArray.length;
  
  
               dataArray.push({dataArrayLength:data});
  
           console.log(dataArray[0]);                                              
  
              }
          });       
      });
  </code></pre>
  
  <p>now i change my code on thebasis of your suggestion i can push data object in array via push fn ... now how do i call inside data from that object ....!</p>
  
  <pre><code>Object {dataArrayLength: Object}
  dataArrayLength: Object
  description: "World famous roasted Chicken, avacado, fresh mushrooms, red onions.       Mozzarella cheese and our secret sauce."
  id: "11"
  images: "/htdocs/kiosk/images/dining/items/pizzas/11.jpg"
  name: "Bella Notte Signature Pizza"
  price: "4.50"
  raters: "10"
  ratings: "1"
  __proto__: Object
  __proto__: Object
  </code></pre>
  
  <p>this is the output of <strong>console.log(dataArray[0])</strong> ...  so now i want to get "id" , "name", "description"  from it how can i do this...????/</p>
  
  <p><strong>MY SOLUTION TO PROBLEM</strong></p>
  
  <pre><code> success:function(data){    
  var dataArrayLength = dataArray.length;
  
  dataArray.push(data);
  dataArray.forEach(function(object,index){
  console.log(object.id);
  console.log(object.name);
  console.log(object.description);
  console.log(object.image);
  console.log(object.ratings);
  });
  </code></pre>
  
  <p>and this is what i want to do ... </p>