JQuery Ajax POST in Codeigniter -


i have searched lot of tutorials post methods , saw answered questions here post still doesn't work...i thought should post here if guys see don't!

my js - messages.js:

$(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 debugging message.               }       return false;  });  }); 

my view - chat.php:

<?php $this->load->js(base_url().'themes/chat/js/messages.js');?> //i use mainframe framework loading script way valid    <form method="post">     <input id="textbox" type="text" name="textbox">     <input id="send" type="submit" name="send" value="send"> </form> 

last my controller - chat.php

//more functions here  function post_action() {        if($_post['textbox'] == "")     {         $message = "you can't send empty text";     }     else     {         $message = $_post['textbox'];     }     echo $message; } 

$(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 debugging message.               }           });// have missed bracket      return false;  });  }); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -