title: Using Ajax on CRUD in Codeigniter
body: <p>Hi all i'm trying to doing C.R.U.D on codeigniter with Ajax but i don't have any experience in Ajax.</p>
  
  <p>So first i have done with add function. Its work but i want after add or edit to refresh table.</p>
  
  <p>This is my modal which is for update :</p>
  
  <pre><code>      &lt;!-- Update  Interview--&gt;
      &lt;div class="modal fade" id="interview" tabindex="-1" role="dialog" aria-labelledby="edit" aria-hidden="true"&gt;
        &lt;div class="modal-dialog"&gt;
      &lt;div id="form-content"&gt;
  
      &lt;div class="modal-content"&gt;
  
            &lt;div class="modal-header"&gt;
          &lt;button type="button" class="close"  data-dismiss="modal" aria-hidden="true"&gt;&lt;span class="glyphicon glyphicon-remove" aria-hidden="true"&gt;&lt;/span&gt;&lt;/button&gt;
          &lt;h4 class="modal-title custom_align" id="Heading"&gt;Edit Your Detail&lt;/h4&gt;
        &lt;/div&gt;
            &lt;div class="modal-body"&gt;
                   &lt;?php
                      echo form_open('vacancy/interview/'. $row['id'], array("class" =&gt; "no-error-margin interview",  "name" =&gt; "interview" , "id" =&gt; "edit-stage"));
                      ?&gt;  
  
  
          &lt;div class="form-group"&gt;
          &lt;label class="control-label"&gt;Type:&lt;/label&gt;
              &lt;select id="classinput" tabindex="1" name="priority" class="form-control required"&gt;
                    &lt;option value="A"&gt;First Interview&lt;/option&gt;
                    &lt;option value="B"&gt;Second Interview&lt;/option&gt;
                    &lt;option value="B"&gt;Final Interview&lt;/option&gt;
              &lt;/select&gt;
           &lt;/div&gt;    
          &lt;div class="date-form"&gt;
  
          &lt;div class="control-group"&gt;
          &lt;label class="control-label" style="margin: 0 30%;padding: 7px;"&gt;When The Interview Will Be?&lt;/label&gt;
  
      &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;div class='col-sm-6 col-md-offset-3'&gt;
              &lt;div class="form-group"&gt;
                  &lt;div class='input-group date' id='datetimepicker1'&gt;
                      &lt;input type='text' class="form-control" /&gt;
                      &lt;span class="input-group-addon"&gt;
                          &lt;span class="glyphicon glyphicon-calendar"&gt;&lt;/span&gt;
                      &lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;/div&gt;
          &lt;/div&gt;
  
        &lt;/div&gt;
  
            &lt;div class="modal-footer "&gt;
          &lt;button id="uin" type="submit" class="btn btn-warning btn-lg" style="width: 100%;"&gt;&lt;span class="glyphicon glyphicon-ok-sign"&gt;&lt;/span&gt; Update&lt;/button&gt;
        &lt;/div&gt;
          &lt;/div&gt;
      &lt;!-- /.modal-content --&gt; 
          &lt;/form&gt;
  
    &lt;/div&gt;
  
        &lt;!-- /.modal-dialog --&gt; 
      &lt;/div&gt;   
      &lt;/div&gt;   
  </code></pre>
  
  <p>i try with following Ajax code for update:</p>
  
  <pre><code>    $("#uin").click(function(){
      $.ajax({
          type: "POST",
          url: "vacancy/interview/&lt;?= $row['id'] ?&gt;", //process
          data: $('form.interview').serialize(),
          success: function(msg){
              alert("Succeess");
              $("#form-content").modal('hide'); //hide popup  
          },
          error: function(){
              alert("failure");
          }
      });
  });
  </code></pre>
  
  <p>But getting Codeigniter Error <code>The action you have requested is not allowed.</code></p>
  
  <p>Controller function:</p>
  
  <pre><code>        public function interview($i) 
  
      {
          $type=$this-&gt;input-&gt;post();
          $this-&gt;vacancies-&gt;update_interview($type, array("id" =&gt; $id));             
      }
  </code></pre>
  
  <p>and Model</p>
  
  <pre><code>    public function update_interview($i) 
  {
      $this-&gt;db-&gt;insert("interviews", $i);
  }
  </code></pre>
  
  <p>Can you tell me where i'm wrong?</p>