title: HTTP Content-Type Header and JSON
body: <p>I have always been trying to avoid using most of the HTTP protocol's properties for the sake of fear of the unknown.</p>
  
  <p>However, I said to myself that I'm going to face fear today and start using headers purposefully. I have been trying to send <code>json</code> data to the browser and use it right away. For example, if I have an Ajax handler function on ready state 4 which looks like so:</p>
  
  <pre><code>function ajaxHandler(response){
      alert(response.text);
  }
  </code></pre>
  
  <p>And I have set the content-type header in my PHP code:</p>
  
  <pre><code>header('Content-Type: application/json');
  echo json_encode(array('text' =&gt; 'omrele'));
  </code></pre>
  
  <p>Why can't I directly access the property from the handler function, when the browser is clearly told that the incoming data is <code>application/json</code>?</p>