title: unable to print array returned by AJAX with javascript
body: <pre><code>function getWriters(cat, lev, id)   
  {
      if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp = new XMLHttpRequest();
      }
      else { // code for IE6, IE5
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200)
  
          {
  
              document.getElementById("writer").innerHTML = xmlhttp.responseText;
              var writer = eval(xmlhttp.responseText);
              document.write(writer)
          }
  
  
      }
  
      xmlhttp.open("GET", "order.php?op=2&amp;id=0&amp;cat=" + cat + "&amp;lev=" + lev, true);
      xmlhttp.send();
  
  
  }
  </code></pre>
  
  <p>xmlhttp.responseText  returns</p>
  
  <pre><code>Array ( [0] =&gt; Array ( [name] =&gt; Unassigned [user_id] =&gt; 2 [writing_level] =&gt; [writing_category] =&gt; ) [1] =&gt; Array ( [name] =&gt; arsalan [user_id] =&gt; 3 [writing_level] =&gt; [writing_category] =&gt; ) [2] =&gt; Array ( [name] =&gt; Shazia [user_id] =&gt; 4 [writing_level] =&gt; [writing_category] =&gt; ) [3] =&gt; Array ( [name] =&gt; janea [user_id] =&gt; 5 [writing_level] =&gt; [writing_category] =&gt; ) [4] =&gt; Array ( [name] =&gt; s [user_id] =&gt; 6 [writing_level] =&gt; [writing_category] =&gt; ) [5] =&gt; Array ( [name] =&gt; iuiui [user_id] =&gt; 8 [writing_level] =&gt; [writing_category] =&gt; ) [6] =&gt; Array ( [name] =&gt; demo [user_id] =&gt; 9 [writing_level] =&gt; [writing_category] =&gt; ) [7] =&gt; Array ( [name] =&gt; wewe [user_id] =&gt; 10 [writing_level] =&gt; [writing_category] =&gt; ) [8] =&gt; Array ( [name] =&gt; Muhammad Zoyeb [user_id] =&gt; 11 [writing_level] =&gt; [writing_category] =&gt; ) [9] =&gt; Array ( [name] =&gt; Atif Rauf Alvi [user_id] =&gt; 12 [writing_level] =&gt; [writing_category] =&gt; ) [10] =&gt; Array ( [name] =&gt; demo-1 [user_id] =&gt; 13 [writing_level] =&gt; [writing_category] =&gt; ) [11] =&gt; Array ( [name] =&gt; ffff** [user_id] =&gt; 14 [writing_level] =&gt; High School,Masters [writing_category] =&gt; Literature and Language,Social Sciences ) ) 
  </code></pre>
  
  <p>i am getting syntax error at  document.write(writer);
  if i remove eval() there is no syntax error.</p>
  
  <p>Can anyone explain how to fix this or some other way to convert the string returned to array.</p>
  
  <p>Thanks </p>