title: JSON returning null on response with jQuery $.ajax
body: <p>I'm trying to get response on ajax post but returning NULL always instead.</p>
  
  <p>I'm thinking that already try everything that I can... but hope somebody will be able to solve it. Thanks very much in advance. And if needs more information please tell me.</p>
  
  <p><em>NOTE: <a href="https://stackoverflow.com/questions/6091851/php-function-not-returning-any-data-to-jquery-ajax-method">PHP function not returning any data to JQuery ajax method</a> - this link didn't help me</em></p>
  
  <p>Here is jquery code:</p>
  
  <pre><code>var post_id=3;
          $.ajax({
  
              type: "POST",
              url: "profile/ajax_get_new_posts",
              data: { post_id : post_id },
              dataType: 'json',
              success: function(data){
  
                  console.log(data);
                  var current_content = $("ol#posts_container").html();
  
                  $("ol#posts_container").html(data.content + current_content);
              }
  
  
          });
  </code></pre>
  
  <p>profile/ajax_get_new_posts (it is .php)</p>
  
  <pre><code>function ajax_get_new_posts(){
  
          header('Content-Type: application/json');
              $post_id=$this-&gt;input-&gt;post('post_id');
              $chat_messages_html='testing';
              $result = array('status' =&gt; 'ok', 'content' =&gt; $chat_messages_html);
              $result=json_encode($result);
              return ($result);
              exit();
          }
  </code></pre>
  
  <p>If I try with var_dump($result);die(); gives me correct result:</p>
  
  <pre><code>string(38) "{"status":"ok","content":"samoletite"}"
  </code></pre>
  
  <p>On the Response Headers gives me Content-Length:0 (it is testing on localhost... not www.mywebsite)</p>
  
  <pre><code> Remote Address:[::1]:80
      Request URL:http://www.mywebsite/bg/profile/ajax_get_new_posts
      Request Method:POST
      Status Code:200 OK
      Request Headersview source
      Accept:application/json, text/javascript, */*; q=0.01
      Accept-Encoding:gzip,deflate
      Accept-Language:en-US,en;q=0.8
      Connection:keep-alive
      Content-Length:9
      Content-Type:application/x-www-form-urlencoded
      Host:localhost
  Origin:http://localhost
  Referer:http://www.mywebsite/bg/profile
  User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36
  X-Requested-With:XMLHttpRequest
  Form Dataview sourceview URL encoded
  post_id:3
  Response Headersview source
  Connection:Keep-Alive
  Content-Length:0
  Content-Type:application/json
  Date:Fri, 31 Oct 2014 13:24:56 GMT
  Keep-Alive:timeout=5, max=97
  .......
  </code></pre>
  
  <p>Console.log gives me:</p>
  
  <pre><code>null ---&gt;ajaxPostProfile.js:28
  Uncaught TypeError: Cannot read property 'content' of null ---&gt;ajaxPostProfile.js:31
  </code></pre>