JS下的网络请求学习记录

常见post数据格式

四种常见post的数据格式

FormData对象的使用

FormData对象的使用官方文档

FileReader对象的使用

FileReader官方文档

Form表单对象的使用

Form官方文档
表单提交:事件和方法提交
Form表单&FileReader:文件的上传和读取

input type = ‘file’

HTMLElement官方文档
input type = 'file'相关属性官方文档介绍

submit方法的使用

submit官方文档

使用web应用中的文件

Using files from web applications

Using XMLHttp​Request

AJax入门官方文档
用XMLHttpRequest 发送表单信息、上传文件
Ajax请求($.ajax()为例)中data属性传参数的形式

Array数组相关的使用

array官方文档

A brief introduction to the submit methods

An html <form> can be sent in four ways:

  • using the POST method and setting the enctype attribute to application/x-www-form-urlencoded (default);
  • using the POST method and setting the enctype attribute to text/plain;
  • using the POST method and setting the enctype attribute to multipart/form-data;
  • using the GET method (in this case the enctype attribute will be ignored).

Now, consider the submission of a form containing only two fields, named foo and baz. If you are using the POST method the server will receive a string similar to one of the following three examples, depending on the encoding type you are using:

  • Method: POST; Encoding type: application/x-www-form-urlencoded (default):

    Content-Type: application/x-www-form-urlencoded
    
    foo=bar&baz=The+first+line.%0D%0AThe+second+line.%0D%0A
    
  • Method: POST; Encoding type: text/plain:

    Content-Type: text/plain
    
    foo=bar
    baz=The first line.
    The second line.
    
  • Method: POST; Encoding type: [multipart/form-data](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#multipartform-data):

    Content-Type: multipart/form-data; boundary=---------------------------314911788813839
    
    -----------------------------314911788813839
    Content-Disposition: form-data; name="foo"
    
    bar
    -----------------------------314911788813839
    Content-Disposition: form-data; name="baz"
    
    The first line.
    The second line.
    
    -----------------------------314911788813839--
    

However, if you are using the GET method, a string like the following will be simply added to the URL:

?foo=bar&baz=The%20first%20line.%0AThe%20second%20line.
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,424评论 0 10
  • Data Visualization with D3 D3: SVG中的jQurey 1. Add Documen...
    王策北阅读 787评论 0 2
  • Correctness AdapterViewChildren Summary: AdapterViews can...
    MarcusMa阅读 8,900评论 0 6
  • 第七期第2篇 饥肠辘辘的完成这篇写作,看到时光倒流,我就想到了他,一个高中同学。坐着时光机,快快回到那一天吧。他牵...
    洁儿洁儿洁儿阅读 100评论 1 1