title: Delete the record using sweetalert js in codeigniter using ajax
body: <p>I want to delete the record using sweetalert js.
  This is my view file:-</p>
  
  <pre><code>&lt;a class="action-link delete" title="delete" href="#" onclick="confirmDelete()"&gt; &lt;i class="glyphicon glyphicon-trash"&gt;&lt;/i&gt; &lt;/a&gt;
  </code></pre>
  
  <p>This is my function:-</p>
  
  <pre><code>function confirmDelete(){
      var id=1;
      swal({
        title: 'Are you sure?',
        text: "You won't be able to delete this!",
        showCancelButton: true,
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        confirmButtonText: 'OK',
        closeOnConfirm: false
      },function (isConfirm) {
          $.ajax({
              url: base_url+"admin/mycontroller/delete",
              type: "POST",
              data: {"id":id},
              dataType:"HTML",
              success: function () {
                  swal("Done!", "It was succesfully deleted!", "success");
              },
              error: function (xhr, ajaxOptions, thrownError) {
                  swal("Error deleting!", "Please try again", "error");
              }
          });
      });
  }
  </code></pre>
  
  <p>This is my controller delete function</p>
  
  <pre><code>public function delete(){
          $id = $this-&gt;input-&gt;post('id');
          $data[ 'status'] = '0';
          $where = array( 'id' =&gt; $id );
          $this-&gt;model-&gt;update( $this-&gt;tablename , $data , $where );
  
      }
  </code></pre>
  
  <p>But not delete the data. Please help me out.</p>