I've a website with a contact form running on a google App Engine. After submitting I'd like to redirect and show a message to the user to let him know the message was sent, this can eighter be a alert message or adding a class to a html tag. How can I do that?
my python file looks like this:
import webapp2
import jinja2
import os
from google.appengine.api import mail
jinja_environment = jinja2.Environment(autoescape=True,loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))
class index(webapp2.RequestHandler):
def get(self):
template = jinja_environment.get_template('index.html')
self.response.write(template.render())
def post(self):
vorname=self.request.get("vorname")
...
message=mail.EmailMessage(sender="...",subject="...")
if not mail.is_email_valid(email):
self.response.out.write("Wrong email! Check again!")
message.to="..."
message.body=""" Neue Nachricht erhalten:
Vorname: %s
... %(vorname,...)
self.redirect('/#Kontakt')
app = webapp2.WSGIApplication([('/', index)], debug=True)
I already tried this in my html file:
<script>
function sentAlert() {
alert("Nachricht wurde gesendet");
}
</script>
<div class="submit">
<input type="submit" value="Senden" onsubmit="return sentAlert()"
id="button-blue"/>
</div>
but it does it before the redirect and therefore doesn't work. Does someone have an idea how to do that?