title: inserting data into database using jquery ajax submit button codeigniter
body: <p>i am trying to insert data into the database using the codeigniter framework, i tried many solutions i couldn't find a problem ., can somebody suggest me the proper answer after adding $this->model->('contact_model'); my page is blank</p>
  
  <p>my controller pages.php</p>
  
  <pre><code>  &lt;?php
  
    class pages extends CI_Controller{
    function index{
    $this-&gt;load-&gt;model('contact_model');      
    $this-&gt;load-&gt;view('pages/index');
            }
  }
   ?&gt;
  
  enter code here
  </code></pre>
  
  <p>my view index.php</p>
  
  <pre><code>&lt;form id="submit" action="&lt;?php echo site_url();?&gt;/models/contact_model"&gt;
  
    &lt;input type="text" id="name" &gt;    
    &lt;input type="email" id="email" &gt;
    &lt;textarea placeholder="Message"  id="message"&gt;&lt;/textarea&gt;
    &lt;button type="button" id="submit1"&gt;Send&lt;/button&gt;
    &lt;a id="ack"&gt;&lt;/a&gt;          
  &lt;/form&gt;
  </code></pre>
  
  <p>my model contact_model.php</p>
  
  <pre><code>&lt;?php
   class contact_model extends CI_Model{    
  
      function insert_entry()
  
      {
          $data = array(
          'name' =&gt; 'name' ,
          'email' =&gt; 'email' ,
          'message' =&gt; 'message');
  
              $this-&gt;db-&gt;insert('contactus', $data); 
      }
                                  }
  </code></pre>
  
  <p>?></p>
  
  <p>custom.js file</p>
  
  <pre><code>$("#submit1").click(function){
  $.post($("#submit").attr("action"),
         $("#submit :input").serializeArray(),
  
  
         function(data)
         {
  
         $("div#ack").html(data); 
         }); 
  
  $("#submit1").submit(function(){
  return false;
     // window.location.href="/application/models/";
   });
  
  
   });
  </code></pre>