How to pass data by 'POST' method to from Javascript to Python
Question: I have this part of script from my GAE application which uses webapp2, which
accepts data from a form using post,

    
    
    class RenderMarksheet(webapp2.RequestHandler):
       def post(self):
         regno = self.request.get('content')  # Here's where I extract the data from the form
         ...
         ...
         ...
         self.response.out.write(template.render(templates/render.html, template_values))
    

And the web form which posts to this script,

    
    
    <form action="/sign" method="post" name="inputform" onsubmit="return validate()">
        Register No : <input type="number" name="regno" placeholder="Your Register No."/> 
                      <input type="submit" value="Get-My-GPA!" >
    </form>
    

Now, I want to manually pass a specific data (a register no.), without using
the submit button from the form, to the python script( or the url, perhaps) ,
using Javascript, say a button that triggers a javascript method.

I have to POST the data using javascript(to implement AJAX). In python I do
this, to post the data to a url,

    
    
    import http.client, urllib.parse
    params = urllib.parse.urlencode({'regno':10109104021})
    headers = {"Content-type": "application/x-www-form-urlencoded",
           "Accept": "text/plain"}
    conn = http.client.HTTPConnection("mydomain:8888")
    conn.request("POST", "/sign", params, headers)
    response = conn.getresponse()
    print(response.status, response.reason)
    data = response.read()
    

How can I post the data to the url, via Jquery or Javascript?


Answer: fastest is to use jQuery and use `$.post()`

