title: echo json encode to jquery
body: <p>I'm looking through lot of example but I cannot figure out why I cannot use the array passed by my php code. I previously echo a single variable and it worked fine. But when I echo an array, there is no result.</p>
  
  
  
  <pre><code>$arr= array('comment_id' =&gt; 100, 'color' =&gt;'green');
  echo json_encode($arr); 
  </code></pre>
  
  <p>in my jquery</p>
  
  
  
  <pre><code>$.ajax( 
   {
        url : $("#dataSaveOpinion" + parameter).data('url'),
        type: "POST",
        data : postData,
        success:function(data, textStatus, jqXHR) 
            {
               var result = jQuery.parseJSON(data);
               $(this).attr('data-url',$("#comment" + parameter).data('url')+result[0]);
  
            },
  </code></pre>
  
  <p><code>result[0]</code>  is undefined</p>