我的Ajax代码无法在codeigniter中发布数据库中的数据

I have the following javascript code that takes a text from a text area and passes it over to a controller which then updates the database. The controller then gets the same text from the db using a model and passes it over to the javascript code to be displayed on a given div of the webpage without refreshing the page. The controller just works fine and returns the text after successful update to the db but my problem is, the ajax code does not post the same message on the given div, it returns the alert error. I dont know how to fix this, pliz help me.

<script type="text/javascript">
        $(function() {

            $('#submit').click(function() {

                //get input data as a array
                var post_data = {
                    'message': $("#message").val(),
                    '<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'
                };

                $.ajax({
                    type: "POST",
                    url: "<?php echo base_url(); ?>index.php/fb/insertByajax",
                    data: post_data,
                    success: function(response) {
                        debugger;
                        // return success message to the id='result' position
                        $("#result").html(response);
                    },
                  error: function() {alert("oops..."); }
                });

            });

        });
    </script>

First, understand that base_url() is different of site_url() exactly because the second one appends /index.php or $config['index_page'] value. So you want:

...

url: "<?php echo site_url('fb/insertByajax'); ?>",

Also check in network session of Chrome's developer tools if there is any bad response from your page.