title: ajax on update data in database using codeigniter
body: <pre><code> &lt;button id="survey_act" method="post" class="tiny ui blue button" type="button" value="&lt;?php echo $surv['id']; ?&gt;"  &gt;Activate Survey&lt;/button&gt;
  </code></pre>
  
  <p>This is my button on click - </p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function(){
         $(document).on("click","#survey_act", function(){ 
             alert(this.value);
                  idx = this.value;
  
      $.ajax({
         type: "POST",
         url: "&lt;?php echo base_url('index.php/admin/survey/act_surveyby_id/')?&gt;/"+idx,
  
        }).done(function(msg){
              if(msg=="success"){
                        alert('You Successfully Activated the Survey!');
               }
  
                     });                       
               });
       });
  
      &lt;/script&gt;
  </code></pre>
  
  <p>This is my javascript -</p>
  
  <pre><code>   public function act_surveyby_id($id){
      $this-&gt;load-&gt;model('survey_m');
      if($this-&gt;survey_m-&gt;insert_activate($id)){                 
                  echo "success";
  
      }else{
  
          echo "invalid";
      }   
  }
  </code></pre>
  
  <p>This is my controller - </p>
  
  <pre><code>         public function insert_activate($id){
  
                  $date = date('m-d-Y',now());
                  $stat = 'Active';
  
                          $data = array(
                                     'issued_date' =&gt;  $date ,
                                     'status' =&gt; $stat            
          );
  
                       $this-&gt;db-&gt;update('survey', $data)-&gt;where('survey_id', $id);
      if($this-&gt;db-&gt;affected_rows()&gt;0){
              return true;
          }else{ 
                      return false;
  
                  }
  
      }
  
  
    }
  </code></pre>
  
  <p>This is my model - </p>
  
  <p>Problem: when i click the activate survey it wont change/update the details of the survey. I really badly need a help regarding with this. Thanks . . .</p>