简体   繁体   English

通过 AJAX 作为 post 发送表单 - 这是更好的内容类型 multipart/form-data 或 application/json

[英]sending form via AJAX as post - which is better content-type multipart/form-data or application/json

Environment - server is node.js with express and appropriate modules.环境 - 服务器是 node.js,带有快速和适当的模块。

I know how to send data using both methods (as multipart/form-data and also application/json).我知道如何使用这两种方法(如 multipart/form-data 和 application/json)发送数据。

For simple form submissions with no file uploads or such, I find it a bit cumbersome to send data using multipart/form-data and would prefer to keep using application/json for my POST requests.对于没有文件上传等的简单表单提交,我发现使用 multipart/form-data 发送数据有点麻烦,并且更愿意继续使用 application/json 来处理我的 POST 请求。

Is there any reason why I should choose to send forms as multipart/form-data over application/json if there is no file upload involved?如果不涉及文件上传,有什么理由我应该选择将 forms 作为 multipart/form-data 通过 application/json 发送?

ie if it is more secure or has some data security benefit?即它是否更安全或有一些数据安全优势?

application/json is better for this case. application/json 更适合这种情况。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 axios 发布请求正在发送请求 header 的 Content-Type: multipart/form-data 导致未定义的 req.body - axios post request is sending a request header of Content-Type: multipart/form-data resulting in undefined req.body 节点 axios 未发送正确的 header:'Content-Type':'multipart/form-data' - Node axios not sending correct header: 'Content-Type': 'multipart/form-data' 如何提取通过 multipart/form-data 发送的文件的 Content-Type - How to extract the Content-Type of a file sent via multipart/form-data 快递邮寄方法不适用于 Content-Type:multipart/form-data - express post method not working with Content-Type:multipart/form-data 在相同的multipart / form-data POST请求中发送JSON和File - Sending JSON and File in same multipart/form-data POST request 将Restangular customPOST图像文件作为Content-Type:multipart / form-data发送到NodeJS(Server) - Restangular customPOST image file as Content-Type:multipart/form-data to NodeJS(Server) 如何在node.js请求中为multipart / form-data设置Content-Type - How to set Content-Type for the multipart/form-data in node.js request request.post继续覆盖内容类型作为content-type:application / x-www-form-urlencoded当指定表单数据时 - request.post continues to override content-type as content-type: application/x-www-form-urlencoded when form-data is being specified 是否可以发送内容类型为multipart / form-data(文件)的Http post请求以及带有数据参数的json对象? - Is it possible to send Http post request with content type multipart/form-data (files) and json object with data parameters alongside? 当设置 header content-type multipart/form-data 时,请求被 CORS-policy No 'Access-Control-Allow-Origin' 阻止 - Request blocked by CORS-policy No 'Access-Control-Allow-Origin' when set header content-type multipart/form-data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM