Simple CGI request and Python reply

G

Greg Corradini

Hello,
I'm trying to implement something very simple without using a Python
WebFramework and I need some advice. I want to send a comma delimited string
from the client to a server-side Python script. My initial plan was to use a
JavaScript function (see below) called "makerequest" that creates a
XMLHttpRequest object and GETs the output from a Python script. I've used
this function before to field requests (in those cases the parameter "data"
passed in the XMLHttpRequest.send() method is null). So I thought I could
just pass some data in and be able to retrieve it with Python. I'm not sure
how to do this. I've used forms with cgi/Python before. However, I don't
want to use a form here. I want Python to handle the "data" variable being
passed without looking for field names using .FieldStorage(). Can that be
done?

Maybe making a request is not the quickest route to do what I want. Ideas?

function makerequest(serverPage,objID,data)
{
var obj = document.getElementById(objID);
xmlhttp.open("GET",serverPage);
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
obj.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(data);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top