I am using mod_python
publisher which is set up and working fine. It allows me to run a Python file in my browser and this Python file has HTML embedded in it. I have defined a click-able image by input type = "image" onclick = "some action"
. When I click the image it takes me to a JavaScript function which then performs window.location = "./move"
which then takes me to a Python function. The problem is that the browser window redirects to that function, i. e. localhost/scripts
becomes localhost/scripts/move
. Is it possible to execute the script without having the browser window change? I can post code if needs be.
In fact, I've just found using Ajax/XmlHttpRequest is simple and work well for that, even if your server is a python SimpleServer style.
You just link this Javascript code from your button:
// send a request, but don't refresh page
xhttp = new XMLHttpRequest();
xhttp.open("GET", "?like", true);
xhttp.send();