|
|
||||||
|
#1
|
|
|
|
|
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? Here is my case: 1. client side: "load" is a javascript function in a html page. It starts the python CGI "test.py" via Apache: <html> <script language="javascript"> .... load("test.py" ); .... </script> .... </html> I want test.py to "return" a "hello" back so the javascript function load takes "hello" as argument like load("hello"). 2. server side: test.py .... #!c:\python24\python.exe def main(): message = 'hello' #return message main() .... Any ideas? Thanks in advance for your help. ouyang |
|
|
|
#2
|
|
|
|
|
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. |
|
#3
|
|
|
|
|
>>>>> zxo102 <zxo102> (z) wrote:
>z> Hi everyone, >z> How can I pass a string generated from python cgi at server side >z> to a >z> javascript function as an argument at client side? >z> I want test.py to "return" a "hello" back so the javascript function >z> load takes "hello" as argument like load("hello"). >z> 2. server side: test.py >z> ... >z> #!c:\python24\python.exe >z> def main(): >z> message = 'hello' >z> #return message >z> main() >z> ... >z> Any ideas? CGI scripts return stuff by printing it, or more generally writing to stdout. So print message should do. The rest is not a Python question but a Javascript question. |
|
|
| Similar Threads | |
| javascript "debugger;" keyword stopped working - no longer breaking in client-side code Was hoping somebody might have experienced this before. I have client-side javascript in my aspx files. For some reason when I place the "debugger;" keyword in my javascript,... |
|
| Client-Side JavaScript Problem in runat=server "<SELECT>" I have some client-side JavaScript that I want to run whenever a pulldown <SELECT> is changes on th client. I'm trying to do this as follows... <select id="MyPulldown"... |
|
| Client Side: "Rich Internet Applications" in Python? Pythonagons, I am considering using (building) a client-side application, rather than a browser, for an Internet application. I am aware there are a few resourcesout there... |
|
| Client-side Javascript validation of "select multiple" for PHP Has anyone here ever done a case where you have a select multiple form element and you have to do both server-side and client-side validation? I am honestly not sure how to... |
|
| Client-side Javascript validation of "select multiple" for PHP Has anyone here ever done a case where you have a select multiple form element and you have to do both server-side and client-side validation? I am honestly not sure how to... |
|
|
All times are GMT. The time now is 07:25 AM. | Privacy Policy
|