title: Uncaught SyntaxError Unexpected Number JSON.parse
body: <p>Trying to get json data through ajax request, but always get this error :</p>
  
  <pre><code>Uncaught SyntaxError Unexpected Number
  </code></pre>
  
  <p>Here is my js code : </p>
  
  <pre><code>var ajaxurl = '&lt;?php echo admin_url('admin-ajax.php'); ?&gt;';
  
      $.ajax({
          url: ajaxurl,
          type: 'POST',
          dataType: 'json',
          data: { action : 'getPills' },
          success: function(data){
              product = JSON.parse(data);
              console.log(product);
          },
          error: function(jqXHR, textStatus, errorThrown) {
              console.log(textStatus, errorThrown);
          }
      });
  </code></pre>
  
  <p>Here is my php code :</p>
  
  <pre><code>add_action('wp_ajax_getPills', 'getPills');
  add_action('wp_ajax_nopriv_getPills', 'getPills');
  
  function getPills(){
  
          $data = array(
              "test" =&gt; 'test'
          );
  
          error_log(json_encode($data), 0);
  
          echo json_encode($data);
  }
  </code></pre>
  
  <p>called error_log to see what json data I trying to receive: </p>
  
  <pre><code>{"test":"test"}
  </code></pre>
  
  <p>I used ajxa+json before on other projects and it was all good. I have no idea how to fix it :(</p>