1

Since mostly a backend guy, I am not sure how can I achieve the following since it requires some interaction with the browser.

So, I have a the following things so far.

A communication protocol where server is in python and client is in javascript code. Ultimately, I want my data to reach to that javascript code.

Now, this data is being captured from browser.

As a practice.. what I am trying to do is.. have two radio buttons on my browser and a submit button

 *radio A *radio B * Submit 

Now, when the user presses submit, I somehow want to create a query "user submitted: A (or B)" and this query i am able to capture on python script.

I am at lost on how to do this.

My guess is that "submit" invokes a python script. But what if my python server is always on .. how do i parse that response from the click of browser to this python server?

3
  • Java is not JavaScript. Which do you mean?
    – Eric
    CommentedFeb 7, 2013 at 0:06
  • 1
    @Eric: yes.. i know.. it has nothing to do with java. sorry that my question is not clear.. [code] javascript--> python--> java [/code] python--> java is a simple socket ..so that protocol is there.. I am now working on how to send data from javascript --> python
    – frazman
    CommentedFeb 7, 2013 at 0:08
  • 1
    To be honest there is too much to answer in 1 question here. Maybe a good place to start would be looking at a post request using jQuery's ajax method?
    – Undefined
    CommentedFeb 7, 2013 at 0:12

1 Answer 1

2

This is the way it usually works:

  1. Client (browser) visits webpage and initiates request to server
  2. Server (in your case, Python) handles request and writes HTML response, including the radio-button form
  3. Client fills out form and hits Submit, triggering another request to the server
  4. Server handles the second request and writes another response (e.g. "Purchase successful", "message posted", etc.).

Note that the second request is a brand-new request. You may want some way of linking the first request to the second one unless the second request is anonymous. Some frameworks will do that for you, but if you are making the server from the ground up you'll want some kind of session mechanism to keep track of state.

To get the client to make the second request, the simplest is to add appropriate action and method attributes to the form element in your HTML. action specifies the URL to access for the form request, and method is either GET or POST. (More advanced usage, e.g. on this site, typically uses AJAX to make the submissions instead).

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.