title: Issues passing json data to build morris.js plot dynamically
body: <p>I want to build a morris.js plot dynamically by using ajax, php, and mysql.</p>
  
  <p>i have been searching with no success how to achieve this.</p>
  
  <p>I get the array data successfully with ajax but now i can't pass these data to build the plot.</p>
  
  <p>From the PHP script i get the following json array:</p>
  
  <pre><code>[{"concurso":"2736","R1":"7","R2":"24","R3":"27","R4":"39","R5":"45","R6":"52","R7":"12"},{"concurso":"2737","R1":"16","R2":"19","R3":"23","R4":"29","R5":"33","R6":"49","R7":"36"},{"concurso":"2738","R1":"4","R2":"6","R3":"20","R4":"21","R5":"45","R6":"55","R7":"38"},{"concurso":"2739","R1":"5","R2":"16","R3":"17","R4":"24","R5":"41","R6":"47","R7":"36"},{"concurso":"2745","R1":"1","R2":"13","R3":"19","R4":"29","R5":"41","R6":"46","R7":"50"}]
  </code></pre>
  
  <p>Where morris.js <em>y</em> is the value after 'concurso', and <em>ykeys</em> are the values after <em>R1</em>, <em>R2</em>, <em>R3</em>, ... <em>R7</em>.</p>
  
  <p>My jQuery looks like this so far:</p>
  
  <pre><code>$.ajax({
      url: "ajax/default_chart_numbers.php",
      cache: false, 
      dataType: "json",
      timeout:3000,
      success : function (data) {
  
       new Morris.Line({
         // ID of the element in which to draw the chart.
         element: 'revancha',
         data: $.parseJSON(data),
         xkey: 'concurso',
         ykeys: ['R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7'],
         labels: ['n1', 'n2', 'n3', 'n4', 'n5', 'n6', 'n7'],
         hideHover: 'auto',
         resize: true
      });
  },
  error : function (xmlHttpRequest, textStatus, errorThrown) {
       alert("Error " + errorThrown);
       if(textStatus==='timeout')
           alert("request timed out");
  } 
  });
  </code></pre>
  
  <p>I can't see the plot. There's nothing. What am i missing?</p>
  
  <p>Well, fortunately i could fix it myself. Here is my working jQuery ☺:</p>
  
  <pre><code>$.ajax({
      url: "ajax/some_handler.php",
      cache: false,
      type: "POST",
      data: {anyVar: 'specialValue4PHPScriptAndDataBaseFilter'},
      dataType: "json",
      timeout:3000,
      success : function (data) {
      //console.log(data); alert(JSON.stringify(data));
  
       Morris.Line({
         element: 'TheElementName',
         data: data,
          xkey: 'someID',
          ykeys: ['R1', 'R2', 'R3', 'R4', 'R5', 'R6'],
          labels: ['n1', 'n2', 'n3', 'n4', 'n5', 'n6'],
          hideHover: 'auto',
          resize: true
      });
  },
  error : function (xmlHttpRequest, textStatus, errorThrown) {
       alert("Error " + errorThrown);
       if(textStatus==='timeout')
           alert("request timed out");
  } /*References: http://stackoverflow.com/questions/22746646/ajax-i-cant-get-data-from-php-by-using-json-encode*/
  });
  </code></pre>