3

i want to create an application in google app engine using python. I have to send a list of json string to python script.I have done the following code but ain't worked.

$.post("/javascriptdata",{v:s},function(data,status) {});

In python script i have a class named javascriptdata to where data has to be send to

import wsgiref.handlers
import json
import sys
import cgi
from google.appengine.ext import webapp
from google.appengine.ext.webapp import Request
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template

class mainh(webapp.RequestHandler):
    def get(self):
        self.response.out.write(template.render("paint.html",{}))

class javascriptdata(webapp.RequestHandler):
    def post(self):
        self.response.headers['content-Type'] = 'html'
        data1=self.request.get('v')
        self.response.out.write("""<html><body>""")
        self.response.out.write(data1)
        self.response.out.write("""</body></html>""")


def main():
    app = webapp.WSGIApplication([
        ('/',mainh),("/save",javascriptdata)], debug=True)
    wsgiref.handlers.CGIHandler().run(app)


if __name__ == "__main__":
    main()

The javascriptdata is associated with the url "/save". I have created a submit button named "save" that would redirect to /save but iam not getting any output. I know it may be a silly mistake but Iam struggling to sort it out. Please suggest me how to post and read the data for this code.

1
  • where is the jQuery code ? Commented Dec 21, 2012 at 7:38

1 Answer 1

3

This seems suspicious:

$.post("/javascriptdata",{v:s},function(data,status) {});

since you don't have a /javascriptdata URL mapped in the python code. Perhaps you meant

$.post('/save', ...?

Alternatively, you could change the WSGIApplication init to be:

...("/javascriptdata",javascriptdata)...

Sign up to request clarification or add additional context in comments.

1 Comment

$.post('/save', ...? is his problem I think

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.