javascript - Tornado doesn't send Ajax response to client -
After submitting the form, the Tornado server does some tests and sends a response to the client, which should show in the current page. Warning .
An empty HTML page is provided instead with a Jason response, but not a as a warning the current page where the form was submitted Was there.
When submitting the form it is sent via post to / dh (DataHandler)
this is Jquery: / P>
$ Post ("/ dh", function (data, status) {warning ("data:" + data + "\ n status:" + status);}, "json"); Turtado code:
Class database: Behinddaler: Deaf Post (self): # Checks are made with the form data received dupinfo = {'Tel': Duptel, 'name': dupname} self.write (json.dumps (dupInfo, default = json_util.default)) self.finish () How to Return
After the "Warning" statement, add return false . This disables the default handling of the browser of the POST event. The default behavior of the browser is to navigate to the new URL, and you want to stop it.
Comments
Post a Comment