title: DataTables json parsing error
body: <p>This is a common question and I have researched all the answers Google can provide so I apologize for asking it again.</p>
  
  <p>Firebug shows the response as </p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  { "aaData" : [ [ "A",
          "0.67",
          "0.66",
          "0.66",
          "0.66",
          "0.78",
          "1.52",
          "0.00",
          "0.00",
          "-15.38",
          "1970-01-01"
        ],
        [ "AA",
          "0.11",
          "0.12",
          "0.12",
          "0.14",
          "0.12",
          "-8.33",
          "0.00",
          "-14.29",
          "16.67",
          "2013-04-08"
        ],
        [ "AACC",
          "0.03",
          "0.04",
          "0.04",
          "0.04",
          "0.10",
          "-25.00",
          "0.00",
          "0.00",
          "-60.00",
          "2013-03-04"
        ],
        [ "AAN",
          "0.50",
          "0.50",
          "0.50",
          "0.50",
          "0.49",
          "0.00",
          "0.00",
          "0.00",
          "2.04",
          "2013-02-04"
        ],
        [ "AAON",
          "0.23",
          "0.23",
          "0.22",
          "0.22",
          "0.20",
          "0.00",
          "4.55",
          "0.00",
          "10.00",
          "2013-03-11"
        ],
        [ "AAP",
          "0.76",
          "0.76",
          "0.76",
          "0.76",
          "0.76",
          "0.00",
          "0.00",
          "0.00",
          "0.00",
          "2013-02-07"
        ],
        [ "AAPL",
          "13.42",
          "13.34",
          "13.30",
          "13.34",
          "15.45",
          "0.60",
          "0.30",
          "-0.30",
          "-13.66",
          "2013-01-    23"
        ]
      ],
    "iTotalDisplayRecords" : "7",
    "iTotalRecords" : "7",
    "sEcho" : 1
  }
  </code></pre>
  
  <p>jsonlint.com says the the json is valid, but why has apache put the Doctype in front of the response? Is this causing the error?</p>
  
  <p>Firebug also reports the headers as :</p>
  
  <pre><code>Connection  Keep-Alive
  Content-Length  798
  Content-Type    application/json
  Date    Wed, 23 Jan 2013 09:18:35 GMT
  Keep-Alive  timeout=5, max=100
  Server  Apache/2.2.22 (Ubuntu)
  X-Powered-By    PHP/5.4.6-1ubuntu1.1
  </code></pre>
  
  <p>I am using the server_processing.php script from DataTables with </p>
  
  <pre><code>header('Content-Type: application/json');
  echo $output;
  </code></pre>
  
  <p>The relevant part of my php is:</p>
  
  <pre><code>    $(document).ready(function() {
                  $('#example').dataTable( {
                      "bProcessing": true,
                      "bServerSide": true,
                      "sAjaxSource": "server_processing.php",
                      "sPaginationType": "full_numbers"
                  } );
              } );
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;div id="dynamic"&gt;
      &lt;table cellpadding="0" cellspacing="0" border="0" class="display" id="example"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Symbol&lt;/th&gt;
              &lt;th&gt;Current Estimate&lt;/th&gt;
              &lt;th&gt;7 days ago&lt;/th&gt;
              &lt;th&gt;30 days ago&lt;/th&gt;
              &lt;th&gt;60 days ago&lt;/th&gt;
              &lt;th&gt;90 days ago&lt;/th&gt;
              &lt;th&gt;% Change Current&lt;/th&gt;
              &lt;th&gt;% Change 7&lt;/th&gt;
              &lt;th&gt;% Change 30&lt;/th&gt;
              &lt;th&gt;% Change 60&lt;/th&gt;
              &lt;th&gt;Next Earnings Date&lt;/th&gt;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td colspan="10" class="dataTables_empty"&gt;Loading data from server&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
      &lt;tfoot&gt;
          &lt;tr&gt;
              &lt;th&gt;Symbol&lt;/th&gt;
              &lt;th&gt;Current Estimate&lt;/th&gt;
              &lt;th&gt;7 days ago&lt;/th&gt;
              &lt;th&gt;30 days ago&lt;/th&gt;
              &lt;th&gt;60 days ago&lt;/th&gt;
              &lt;th&gt;90 days ago&lt;/th&gt;
              &lt;th&gt;% Change Current&lt;/th&gt;
              &lt;th&gt;% Change 7&lt;/th&gt;
              &lt;th&gt;% Change 30&lt;/th&gt;
              &lt;th&gt;% Change 60&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/tfoot&gt;
     &lt;/table&gt;
  </code></pre>
  
  <p>I've lost many hours trying to solve this so am very grateful for any help.</p>