Welcome Guest, Not a member yet? Register   Sign In
when deleting record from DB the page cannot be rediirected using AJAX
#1

Code:
View
******
<td align="center">
<a href="<?php echo base_url().'Users/deleteFile/'.$row['markid']; ?>" onclick="return confirm('Are you sure to delete data?')"  name="idv"  <i class="fa fa-remove" style="font-size:25px;color:red"></i>
</td>
Code:
Controller
**********
public function deleteFile($markid)
 {
     if ($this->User_Model->delete_file($markid))
     {
         $status = 'success';
         $msg = 'File successfully deleted';
         redirect('Users/upload');
         
     }
     else
     {
         $status = 'error';
         $msg = 'Something went wrong when deleting the file, please try again';
     }
     echo json_encode(array('status' => $status, 'msg' => $msg));
     //redirect('Users/upload','refresh');
   
 }

Code:
Model
*******
public function delete_file ($markid){
       $this->db->where('certid', $markid);
       $this->db->delete('gallery');
       if ($this->db->affected_rows() == '1')
   {
     return TRUE;
   }
   
   return FALSE;        
   }
the records are successfuly deleted, but the page cannot redirect it goes to dashboard. any alternate option suggestion please.
Reply


Messages In This Thread
when deleting record from DB the page cannot be rediirected using AJAX - by kvanaraj - 10-04-2018, 04:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB