function proc($request_type = '') { $this->load->helper('url'); if ($action = Datagrid::getPostAction()) { $error = ""; switch ($action) { case 'delete': if (!$this->Datagrid->deletePostSelection()) { $error = 'Items could not be deleted'; } break; } if ($request_type != 'ajax') { $this->load->library('session'); $this->session->set_flashdata('form_error', $error); redirect('test/index'); } else { echo json_encode(array('error' => $error)); } } else { die("Bad Request"); } }