title: Convert string to array in ajax call in javascript
body: <p>I am making an ajax call and getting back result from array that looks like <code>result = [one, two, three];</code></p>
  
  <p>I need to convert this to an array and iterate it. Since my string has no quotes around values array isn't read correctly.</p>
  
  <p>Here is my code, if you can please show me correct way to do it. Thanks.</p>
  
  <pre><code>xmlhttp.open("POST","SearchServlet", true);
  xmlhttp.onreadystatechange = 
      function(){
           if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
                resultData = xmlhttp.responseText; 
            // resultData = [one, two, three];
  
                // need to make valid array to iterate it 
                for (var i = 0; i &lt; resultData.length; i++) {
                    console.log(resultData[i]);
                }
          }
      };  
  </code></pre>