In python CGI, how to pass "hello" back to a javascript function as an argument at client side?

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue Oct 13 10:52:37 CEST 2009


zxo102 a écrit :
> Hi everyone,
>     How can I pass a string generated from python cgi at server side
> to a
> javascript function as an argument at client side?
> 

This is common HTTP / javascriot stuff - nothing related to Python. 
First learn about the HTTP protocol - something you obviously need if 
doing web development -, then eventually google for XMLHttpRequest (or 
'ajax').

To make a long story short: the client side doesn't give a damn about 
how the server-side works - it requests an url (-> read the part about 
"HTTP Request" in the rfc), waits for the response (-> read the part 
about "HTTP Response" in the rfc), and whatever it wants with the 
response. FWIW, HTTP requests can have a "query string" containing 
arguments.

 From the server-side POV, your CGI script doesn't "return" anything - 
it generates a HTTP response, which will be sent back to the client by 
Apache.



More information about the Python-list mailing list