所以我的 javascript 中有一个 ajax 函数,可以发布到我的 Flask 后端。
我可以成功调用/another_ajax_url 吗?
@app.route('/myroute', methods=['POST, GET'])
def test():
a = 2 + 2
requests.post('/another_ajax_url', data = a)
#do the other stuff and return to /myroute
b = 3 + 3
return jsonify(b=b)
最佳答案
是的,您可以这样做,但您可能更喜欢使用类似 celery 的内容。如果您不需要结果。
在客户端请求中执行 http 请求将阻止客户端,直到请求完成并执行其余代码。
关于javascript - Flask - 我可以在 AJAX 调用过程中执行另一个请求吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40993659/