title: update status value in backend while click on button in codeigniter
body: <p>In <code>view_candidates</code> form in my application, I have a button with text <code>REQUEST CONTACT INFO</code>. When I click on the button, the text will be changed automatically to <code>FINISH</code>.</p>
  
  <p><strong>Now what happens:</strong> When I refresh the page the button text automatically changes to <code>REQUEST CONTACT INFO</code>.</p>
  
  <p>To overcome this, I gave a <code>status</code> column in my database. </p>
  
  <p><strong>What I want:</strong></p>
  
  <p>Once user click on the button, the <code>status</code> should change from 0 to 1.</p>
  
  <p>With <code>status</code>, I want to display my button text like: if status=0 button should be <code>REQUEST CONTACT INFO</code>, else it should be <code>FINISH</code>.</p>
  
  <p><strong>Button code:</strong></p>
  
  <pre><code>&lt;td&gt;
      &lt;button type="button" id="button" class="btn btn-info" onclick="getConfirmation(id);"&gt;
          &lt;b&gt;REQUEST CONTACT INFO&lt;/b&gt;
      &lt;/button&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p><strong>SCRIPT:</strong></p>
  
  <pre><code>&lt;script&gt;
       function  getConfirmation(id)
       {
  
          var retVal = confirm("your request is confiremed ?");
          if(retVal)
                          {
  
                            $('#button').text('Finish');
  
          $.ajax({
                  url: "Candidate/user_view_candidates/change_status",
                  type: "post",
                  data: id,
                  success: function (response) 
                  {
                   //location.reload();              
                   alert('success');
                  }
  
              });
          }
      }
  
      &lt;/script&gt;
  </code></pre>
  
  <p>Controller code:</p>
  
  <pre><code>    public function  change_status()
  
   { 
  
       $id = $this-&gt;input-&gt;post('candidate_id');
       $status = $this-&gt;db-&gt;query("select status from candidates_details          where id = candidate_id")-&gt;row()-&gt;status;
      if($status==0)
      {
          $status = 1;
      } 
      else 
      {
          $status = 0;
      }
  
      $data=array('status'=&gt;$status);
      $this-&gt;db-&gt;where('candidate_id',$id);
      $this-&gt;db-&gt;update('candidates_details',$data);
  }
  </code></pre>
  
  <p>Can someone help me?<br> Thanks in advance.</p>