2018-04-13 02:06:02 +08:00
|
|
|
{% extends 'base.html' %}
|
|
|
|
|
|
|
|
{% block intro %}
|
|
|
|
<a href="https://jquery.com/">jQuery</a> is a popular library that
|
|
|
|
adds cross browser APIs for common tasks. However, it requires loading
|
|
|
|
an extra library.
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block script %}
|
|
|
|
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
|
|
|
<script>
|
|
|
|
function addSubmit(ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
$.ajax({
|
|
|
|
method: 'POST',
|
2018-04-13 03:17:14 +08:00
|
|
|
url: {{ url_for('add')|tojson }},
|
2018-04-13 02:06:02 +08:00
|
|
|
data: $(this).serialize()
|
|
|
|
}).done(addShow);
|
|
|
|
}
|
|
|
|
|
|
|
|
function addShow(data) {
|
|
|
|
$('#result').text(data.result);
|
|
|
|
}
|
|
|
|
|
2018-04-13 03:17:14 +08:00
|
|
|
$('#calc').on('submit', addSubmit);
|
2018-04-13 02:06:02 +08:00
|
|
|
</script>
|
|
|
|
{% endblock %}
|