Reputation: 69
I'm trying to figure out what I'm doing wrong here. I have this for my jQuery code and I also have a php controller function called delete that looks like this. Right now when I cxlick on the element with a class of delete it tries to make a request to this page and it can not be found.
mysite.com/cms/ctrlpanel/users/delete
public function delete($user_id)
{
}
$route['cms/ctrlpanel/users/delete/(:num)'] = 'users/delete/$1';
$('.delete').click(function(e){
var element = $(this);
e.preventDefault();
$.post('/cms/ctrlpanel/users/delete', { 'user_id' : element.attr('rel') }, function(data)
{
), 'json');
});
Upvotes: 1
Views: 85
Reputation: 2811
$('.delete').click(function(e){
var element = $(this).attr('rel');
e.preventDefault();
$.post('users/delete/' + element);
});
Oops.
public function delete($user_id){
$user_id = (int)$user_id;
Upvotes: 2