提问人:cmdedj 提问时间:10/19/2023 更新时间:10/19/2023 访问量:18
为什么我使用 enctype='application/json' 但CONTENT_TYPE仍然是 application/x-www-form-urlencoded
why i use enctype='application/json' but CONTENT_TYPE still be application/x-www-form-urlencoded
问:
<form enctype='application/json' action="{% url 'xxx' %}" method="post">
{% csrf_token %}
<input type='number' name='bottle-on-wall' value='1'>
<input type='number' name='bottle-on-wall' value='2'>
<input type='number' name='bottle-on-wall' value='3'>
<button type="submit">send</button>
</form>
CONTENT_TYPE 'application/x-www-form-urlencoded'
如何将表单数据作为JSON发送到服务器
答:
0赞
Jeremy Fiel
10/19/2023
#1
用multipart/form-data
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#enctype
<form enctype='multipart/form-data' action="{% url 'xxx' %}" method="post">
{% csrf_token %}
<input type='number' name='bottle-on-wall' value='1'>
<input type='number' name='bottle-on-wall' value='2'>
<input type='number' name='bottle-on-wall' value='3'>
<button type="submit">send</button>
</form>
评论