title: send array from controller to a view using JSON in MVC
body: <p>I have this code :  </p>
  
  <pre><code>var mapcity = new Array([]);              
  
           $.ajax({
               type: 'GET',
               url: '/home/DrawMap',
               dataType: 'json',
               success: function (data) {
  
                   var len = data.length;
  
                   for (var i = 0; i &lt; len; i++) {
  
                      // mapcity['' + data[i].name + ''] = { center: new google.maps.LatLng(data[i].x, data[i].y), population: data[i].population, name: '' + data[i].name + '' };
                       mapcity['' + data[i].name + ''] = { center: new google.maps.LatLng(data[i].x, data[i].y), population: data[i].population, name: ''+data[i].name+'' };
                       //newarr[i] = data[i].name;
  
                     alert(mapcity[0].population)
                   }
                   }
           });
  }
  </code></pre>
  
  <p>This is a part of my code, and this is the function from controller :</p>
  
  <pre><code>public ActionResult DrawMap() {   
  
    string data = "[{ 'x':31.949454,'y': 35.932913,'population':50000,'name':'amman'},{ 'x':33.79,'y': 33.39,'population':100000,'name':'Zarqa'}]";
          data=data.Replace("'","\"");
          return this.Content(data, "application/json");       
  
      }
  </code></pre>
  
  <p>When I run this, its het the JSON data from the controller but without saving it into the mapcity variable!
  And it does nothing. how can I solve it and what iam doing wrong?</p>