How to post data structure like json to flask?

后端 未结 2 1237
失恋的感觉
失恋的感觉 2021-02-13 11:43

I have a data structure like this:

\"enter

I\'m try to send it to server by $.ajax

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-13 11:53

    If you inspect the POST being submitted by jQuery, you will most likely see that content is actually being passed as content[]. To access it from the Flask's request object, you would then need to use request.form.getlist('content[]').

    If you would prefer to have it passed through as content, you can add traditional: true to your $.ajax() call.

    More details about this can be found in the 'data' and 'traditional' sections of http://api.jquery.com/jQuery.ajax/.

提交回复
热议问题