Home / File/ xhr.html — flask Source File

xhr.html — flask Source File

Architecture documentation for xhr.html, a html file in the flask codebase.

Entity Profile

Source Code

{% extends 'base.html' %}

{% block intro %}
  <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest"><code>XMLHttpRequest</code></a>
  is the original JavaScript way to make requests. It's natively supported
  by all browsers, but has been superseded by
  <a href="{{ url_for("index", js="fetch") }}"><code>fetch</code></a>.
{% endblock %}

{% block script %}
  <script>
    function addSubmit(ev) {
      ev.preventDefault();
      var request = new XMLHttpRequest();
      request.addEventListener('load', addShow);
      request.open('POST', {{ url_for('add')|tojson }});
      request.send(new FormData(this));
    }

    function addShow() {
      var data = JSON.parse(this.responseText);
      var span = document.getElementById('result');
      span.innerText = data.result;
    }

    var form = document.getElementById('calc');
    form.addEventListener('submit', addSubmit);
  </script>
{% endblock %}

Frequently Asked Questions

What does xhr.html do?
xhr.html is a source file in the flask codebase, written in html.
Where is xhr.html in the architecture?
xhr.html is located at examples/javascript/js_example/templates/xhr.html (directory: examples/javascript/js_example/templates).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free