You do not know the underlying architecture of FormData

FormData what to pay attention to when uploading files?

	input type="file"  
		要有name属性属性值=输入框的type值(建议)
	根据后端提供的接口参数说明,来设置input name的属性值
	上传文件前端很方便,难在后端。
	表单中的button默认有一个跳转效果
		button type="button"

1. The value of how to use a form to collect FormDate

	通过FormData批量搜集表单信息

What steps are FormDte

	 //收集用户信息
		var fd = new FormData(document.ElementById('myForm'));
		搜集到的是一个键值对

Delete name value input box

		fd.delete(‘要删掉的输入框name属性值’)
	向fd对象添加一个键值对
		fd.append(‘phone’,‘131525525555’)

View fd value stored in the object form elements

		fd.get(“表单元素的name属性值”)
		console.log(fd.get('userName'))
		console.log(fd.get('userPassword'))

Native ajax request issued fd

		// 2.向接口发请求
            // 当发post时,如果通过formData收集参数,则
            // (1)不要设置请求头
            // (2)直接把fd对象放在send()中。xhr.send(fd)
            var xhr = new XMLHttp

Guess you like

Origin blog.csdn.net/zmmsdk/article/details/103324436