2016-12-06 103 views
0

所以我有一个在我的JavaScript发布到我的烧瓶后端的ajax函数。烧瓶 - 我可以在AJAX调用中执行另一个请求吗?

我可以成功调用/ 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) 

回答

1

是的,你可以这样做,但你可能更愿意使用像celery如果你不需要的结果。

在客户端请求中执行http请求会阻止客户端,直到请求完成并执行其余代码。

+0

芹菜看起来像我实际需要的东西。谢谢。 –

相关问题