表单数据和请求负载之间的区别是什么? [英] What is the difference between form data and request payload?

查看:776
本文介绍了表单数据和请求负载之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我送一个AJAX发布采购信息,并发送参数查询字符串在send()方法,

When I send an AJAX Post request and send parameters in queryString in send() method,

Chrome开发工具的XHR捕捉工具显示在请求负载的参数。 当我使用jQuery的岗位职能, 该工具显示了在表数据部分参数。

Chrome Developer Tool's XHR capture tool shows the parameters under request payload. and when I use jquery's post function, The tool shows parameters under Form Data section.

有什么区别?

推荐答案

您还没有提供如何使用发送功能足够的信息,但我认为你不设置MIME类型来指定要发送表单数据。

you have not provided enough information how you use the send function, but I assume that you do not set mime type to specify you are sending form data

xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");

发送的数据,在此情况下连接codeD,你恩codeA查询字符串

the data sent are in this case encoded as you encode a query string

xhr.send("name=foo&value=bar");

否则将无法被开发者工具PTED为形式的数据除$ P $。

otherwise it will not be interpreted as form data by Developer Tools.

jQuery也多数为你的工作在这方面。

jquery does majority of work for you in this regard.

更新::要明确回答的区别是什么?

Update: To answer explicitly what is the difference...

  • 如果一个请求(通常是POST)具有内容类型头设置为应用程序/ x-WWW的形式urlen codeD 体预计将在标准的查询字符串与URL-CN codeD的 = 的对通过&功放连接; 表格数据部分则显示了键值参数(查看时解析)。这种方式是在许多过去更常见,因为它是一个缺省HTML表格

  • if a request (typically POST) has Content-type header set to application/x-www-form-urlencoded the body is expected to be in the form of a standard querystring with url-encoded key=value pairs joined by &. Form data section then shows the key-value parameters (when viewed parsed). This way was much more common in past because it is a default for HTML forms.

另外一些情况下显示在请求负载部分(与时下解析为便于阅读,以及像JSON常见格式)。

other cases are shown in Request payload section (and nowadays parsed for readability as well for common formats like JSON).

这篇关于表单数据和请求负载之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆