title: How do I debug jQuery.post() with JSON as dataType?
body: <p>I tried to avoid asking questions here and use the search function all the time, but I can't really find a solution for my problem:</p>
  <p>I'm using jQuery to execute a PHP script that gives me values, which I then use to change the content of my HTML elements. My code looks like this:</p>
  <pre><code>  $.post(
      &quot;classes/Damage.php&quot;, {
          id: id,
          action: action
      },
      function(data, status) {
          console.log(data);
          $(&quot;#element1&quot;).text(data.a);
          $(&quot;#element2&quot;).text(data.b);
  },
  &quot;json&quot;);
  </code></pre>
  <p>My PHP looks like this:</p>
  <pre><code>  $data = array(&quot;a&quot; =&gt; &quot;info1&quot;, &quot;b&quot; =&gt; &quot;info2&quot;);
    header('Content-type: text/javascript');
    echo json_encode($data);
  </code></pre>
  <p>The problem that I have is when my PHP script isn't working properly, the jQuery code doesn't execute and I have to manually search for the error. How do I debug this the right way?</p>