title: Javascript assign functions returned array to another array with all elements
body: <p>In $(document).ready I am making in ajax request in a function, which returns json data which I add to an array. I am returning the array from that function but when I try to assign whats returned to another array my alert doesn't show an array full of values.</p>
  
  <pre><code> function retrieveGroupNames() {
          var rows = new Array();
          $.ajax({
              type: "POST",
              url: '@Url.Action("LookUpGroupName", "UserManager")',
              dataType: "json",
              data: {},
              success: function (data) {
                  for (var i = 0; i &lt; data.length; i++) {
                      rows[i] = {
                          data: data[i],
                          value: data[i].group,
                          result: data[i].group
                      }
  //                    alert(data[i].group);
                      //                    alert(data[1].group);
                  } // end of for loop
                  //                alert(rows[1].value);
  
  
              } // end of success
          });   // end of ajax
  //        alert(rows); data here
          return rows;
  
      } // end of function
  
  $(document).ready(function () {
          chkSelection();
          var rows = [];
          rows = retrieveGroupNames();
          alert(rows);
      });
  </code></pre>
  
  <p>Some help please? Thanks!</p>