Код: Выделить всё
/app/main/routes.py
/app/main/templates/main/afile.html
/app/static/javascript/ascript.js
- в файле.html:
Код: Выделить всё
- в маршрутах:
Код: Выделить всё
@bp.route("/ajax_func", methods=["GET", "POST"])
def ajax_func():
return jsonify( {'data': 'hello'} )
- в ascript.js:
Код: Выделить всё
$.ajax({
url: "{{ url_for('main.ajax_func') }}",
type: "POST",
data: "whatever",
success: function (data) { alert(data); }
});
Код: Выделить всё
afile.htmlплане, но я не могу получить правильный URL-адрес (всегда получаю ответ 404 html).
Как правильно указать URL-адрес в вызове ajax?
Подробнее здесь: https://stackoverflow.com/questions/793 ... le-with-en
Мобильная версия