title: JQuery Ajax POST in Codeigniter
body: <p>I have searched a lot of tutorials with POST methods and saw answered questions here too but my POST still doesn't work...I thought i should post it here if you guys see something that i don't!</p>
  
  <p><strong>My js - messages.js:</strong></p>
  
  <pre><code>$(document).ready(function(){   
  
      $("#send").click(function()
      {       
       $.ajax({
           type: "POST",
           url: base_url + "chat/post_action", 
           data: {textbox: $("#textbox").val()},
           dataType: "text",  
           cache:false,
           success: 
                function(data){
                  alert(data);  //as a debugging message.
                }
  
       return false;
   });
   });
  </code></pre>
  
  <p><strong>My view - chat.php:</strong></p>
  
  <pre><code>&lt;?php $this-&gt;load-&gt;js(base_url().'themes/chat/js/messages.js');?&gt; //i use mainframe framework which loading script this way is valid
  
  
  
  &lt;form method="post"&gt;
      &lt;input id="textbox" type="text" name="textbox"&gt;
      &lt;input id="send" type="submit" name="send" value="Send"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Last <strong>My controller - chat.php</strong></p>
  
  <pre><code>//more functions here
  
  function post_action()
  {   
      if($_POST['textbox'] == "")
      {
          $message = "You can't send empty text";
      }
      else
      {
          $message = $_POST['textbox'];
      }
      echo $message;
  }
  </code></pre>