I am trying to send an id number to my weppy backend via ajax I have tried as many things as I can think of but am sure I just don't understand how to do it.
I have collected an id from my HTML page on click and would like to send it to the server script right now my ajax looks like
$(.testclick).click(function(e){
var idnum = e.target.id;
ajax("{{=url('post')}}", [], ':eval');
});
I have tried including the idnum variable in multiple places hoping to figure it out with no such luck
the post function looks like
@app.route()
def post(idnum):
idnum = idnum
print(idnum)
return
right now I am just trying to make it work it doesn't actually do anything but print to the console atm
thanks in advance!
In order to run python script from javascript you can use CGI. Here is the javascript code:
Python script (sample.py):
To get both scripts working you need to have a web server and configure it to execute python script. Here's [a link] https://www.linux.com/blog/configuring-apache2-run-python-scripts