Upon form submit the Tornado server does some checks and sends a response back to the client, which should appear in that current page as an alert
.
Instead a blank html page is rendered with the Json
response, but not as an alert
on the current page where the form was submitted.
On submit the form is sent via post
to /dh (DataHandler)
This is the Jquery:
$.post("/dh",function(data,status){
alert("Data: " + data + "\nStatus: " + status);
},"json");
The Tornado code:
class DataHandler(BaseHandler):
def post(self):
# Checks are done with form data received
dupInfo={
'tel' : duptel,
'name' : dupName
}
self.write(json.dumps(dupInfo, default=json_util.default))
self.finish()
So how can you return this json to the current page?