Using GET() parameters in a python script
Using GET() parameters in a python script
(OP)
Hi All,
I am trying to send some values to a python script using an AJAX call. The AJAX is calling the script properly because if I plug the values directly into the script it executes properly.
The problem I am having is when I try to send the values to my script by embedding them in the URL. Here is the JavaScript where I am sending the parameters:
and here is the function I am trying to parse the url with:
I have researched and the best I could find was the python get() method but every example was using a URL that was included and parsed in the same python script. I don't know how I would use the get() method with a URL that was being sent to the script.
Any help is appreciated.
Thanks in advance,
Ken
I am trying to send some values to a python script using an AJAX call. The AJAX is calling the script properly because if I plug the values directly into the script it executes properly.
The problem I am having is when I try to send the values to my script by embedding them in the URL. Here is the JavaScript where I am sending the parameters:
CODE --> JavaScript
function sndCmd(devID, cmd){ // alert(devID); // alert(cmd); var command = new XMLHttpRequest(); command.onreadystatechange = function() { if (command.readyState == 4 && command.status == 200) { var result = command.responseText; } }; command.open("GET", "http://localhost/cgi-bin/kipro/transport.py?devID="+devID+"&cmd="+cmd, true); command.send(); }
and here is the function I am trying to parse the url with:
CODE --> python
#!C:\Python27\python.exe -u import cgi import kipro data = cgi.fieldStorage() devID = data.getvalue('devID') cmd = data.getvalue('cmd') client = kipro.Client(devID) client.cmd()
I have researched and the best I could find was the python get() method but every example was using a URL that was included and parsed in the same python script. I don't know how I would use the get() method with a URL that was being sent to the script.
Any help is appreciated.
Thanks in advance,
Ken