[eluser]hamzakhan[/eluser]
dont want to refresh page when delteing user by using ajax jquery.
how i can do that??
my controller
Code:
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->get_users();
}
function get_users()
{
$this->load->model('Mwelcome');
$data['query'] = $this->Mwelcome->get_names();
$this->load->view('welcome_message', $data);
}
function delete()
{
$id = $this->uri->segment(3, 0); // get id
// echo 'hamza testing'.$id;
/*
$id = $this->uri->segment(3, 0); // get id
$url = $_SERVER['QUERY_STRING'];
*/
$this->load->model('Mwelcome');
$this->Mwelcome->delete_names($id);
// echo 'Deleted Successfully';
redirect('welcome/get_users');
// $this->get_users();
// $this->load->view('welcome_message', $data);
}
function add()
{
$this->load->model('Mwelcome');
$this->Mwelcome->add_name();
redirect(index_page());
// $this->load->view('welcome_message', $data);
}
function register()
{ // register user
$this->load->view('register');
}
}
/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
view
Code:
<?php
$counter = count($query);
echo "<table border=\"1\" align=\"center\" width=100%>";
echo "<tr><th> id </th>";
echo "<th> names </th></tr>";
$counter = 1;
foreach($query as $content)
{
echo "<tr><td>";
echo $counter;
echo "</td><td>";
echo $content->name;
echo "</td><td>";
//
$att_anchor_dele = array('href'=>'#');
//echo anchor('','Delete',$att_anchor_dele);
echo '<a >id.')" >Delete</a>';
echo "</td></tr>";
$counter ++;
}
echo "</table>";