0

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.

10
  • Is that your own javascript function which resets window.location? What does the move function do? Commented Sep 30, 2015 at 7:36
  • yes it basically justs redirects to the python function. Move allows for a servo motor to move. So i have an arrow button that when i click it causes a servo motor to turn Commented Sep 30, 2015 at 7:43
  • Can't you redirect back to /scripts at the end of move? Commented Sep 30, 2015 at 7:46
  • Yes i can but i have video feed that keeps refreshing when i do that. So basically the whole page refreshes again and the video feed stops and starts Commented Sep 30, 2015 at 7:50
  • Why are you setting window.location? Can't you just call move()? Commented Sep 30, 2015 at 7:50

1 Answer 1

0

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();
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.