title: javascript jquery and using eval
body: <p>i am currenty using jquery plugin to read a data file (data.html)</p>
  
  <p>data.html has below format</p>
  
  <pre><code>[10,20,30,40,50]
  </code></pre>
  
  <p>my jquery data request and the javascript to return values is below</p>
  
  <pre><code>function test(){
    var result=$.ajax({
      url:'data.html',
      type:'get',
      dataType:'text',
      async:false,
      cache:false
    }).responseText
  return result;};
  var my=test();
  alert(my[0])
  </code></pre>
  
  <p>i want to get these values in the array format i.e i want my[0] to be value 10, but instead i get "[". 
  If i use eval function</p>
  
  <pre><code> my=eval(test());
  </code></pre>
  
  <p>i can get 10, but is there any other better way to store the returned ajax calls into an array instead of string?</p>
  
  <p>Thanks</p>
  
  <p>i tried the below answer and i am bit puzzled, the follow code results in myArray is null (in firebug), but i put async:false then it works. why do i need async:false to store the values into array ? (http://stackoverflow.com/questions/133310/how-can-i-get-jquery-to-perform-a-synchronous-rather-than-asynchronous-ajax-req)</p>
  
  <pre><code>jQuery.extend({getValues: function(url) {
  var result = null;
  $.ajax({
      url: url,
      type: 'get',
      dataType: 'json',
      cache: false,
      success: function(data) {result = data;}
      });
  return result;}});
  myArray=$.getValues("data.html");
  alert(myArray[1]);
  </code></pre>