Ajax Pass ID to Controller Function

51 views
Skip to first unread message

Cristina Sig

unread,
Sep 21, 2019, 9:20:45 PM9/21/19
to web2py-users
Hello everybody,

I'm struggling with this right here. I want to pass an id from view to a controller function so I can delete a record from database.
So far this is what I got.
I would appreciate some light on this because I don't know what I'm doing wrong.

Thanks!

view
$('#warning').on('click', function(){
   
var iduser= $('#id').val();
    ajax
('{{=URL('Tools', 'userdelete', args=)}}' , [], iduser);
})

controller (Tools.py)
def userdelete():
    rec-id = request.args(0)
    crud.delete(db.People, rec-id, message=T('Deleted'))




Paco Bernal

unread,
Sep 24, 2019, 9:50:53 AM9/24/19
to web2py-users
Hi

ajax('{{=URL('Tools', 'userdelete')}}/'+iduser , [], '');


Regards

Reply all
Reply to author
Forward
0 new messages