title: Codeigniter weird ajax result in controller
body: <p>I've started a codeigniter project and now a i have to do an ajax call to a special controller.</p>
  
  <p>It goes something like this:
  - I have two select fields: 1 for selecting county's and the other one must populate with the city's in the selected county.</p>
  
  <p>The problem is I get a really weird result when I send the selected county id to the ajax controller.</p>
  
  <p>If I put something like this in the controller : echo "a $county_id" in the controller it will give me the response : a [selected county_id], but if I only echo out the county id it shows some json empty response, and I don't know what's wrong, below is the code:</p>
  
  <ol>
  <li><p>the ajax(jquery) call.</p>
  
  <pre><code> $(document).ready(function(){
          $('#judet').change(function(){
              var county = $( "select option:selected" ).val();
  
              $.ajax({
                  type:'POST',
                  /*dataType: "json",*/
                  data:{cou_county:county},
                  url:'&lt;?php echo base_url("ajax_controller/") ?&gt;',
                  success:function(){
                      console.log('id_judet:' + county);
                  },
                  error:function(mesaj){
                      console.log("there's an error");
                  }
              });
          });
  
      });
  </code></pre></li>
  <li><p>The codeigniter ajax_controller Controller:</p>
  
  <pre><code>    public function index()
      {       header('content-type text/html charset=utf-8');
          $cou_county = $this-&gt;input-&gt;post('cou_county');
          $decodedCounty = $cou_county;
          echo "$decodedCounty";
      }
  </code></pre>
  
  <p>The county and city selectors are two simple select inputs with id's I'll post some pictures if you think i haven't explained it well eneugh.</p></li>
  </ol>
  
  <p>EDIT: the ajax call does access the controller, where i actually echo that id, but in the response i get some weird json thingy instead of the number, like in the picture below:</p>
  
  <p><a href="https://i.stack.imgur.com/bs8T2.jpg" rel="nofollow noreferrer">the response</a></p>
  
  <p>Thanks for taking the time to read this, and thanks in advance to those of you who take the time to help a brother out.</p>