plain.html
This file
Path
examples/javascript/js_example/templates/plain.html
28 lines · 832 bytes · HTML
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 47e165d point at it.
Merge pull request #3673 from stat1c-void/pr-api.rst-request-link-20200702David Lordbefore adoption47e165d
lines 1–28why, one step back1{% extends 'base.html' %}23{% block intro %}4 <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest"><code>XMLHttpRequest</code></a>5 is the plain JavaScript way to make requests. It's natively supported6 by all browsers.7{% endblock %}89{% block script %}10 <script>11 function addSubmit(ev) {12 ev.preventDefault();13 var request = new XMLHttpRequest();14 request.addEventListener('load', addShow);15 request.open('POST', {{ url_for('add')|tojson }});16 request.send(new FormData(this));17 }1819 function addShow() {20 var data = JSON.parse(this.responseText);21 var span = document.getElementById('result');22 span.innerText = data.result;23 }2425 var form = document.getElementById('calc');26 form.addEventListener('submit', addSubmit);27 </script>28{% endblock %}