user1724167
user1724167

Reputation: 69

Page not found upon jquery request

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

Answers (1)

keyboardSmasher
keyboardSmasher

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

Related Questions