用户工具

站点工具


web:form
  • ajax表单提交
<form enctype="application/x-www-form-urlencoded">

$.ajax({
	type : "POST",
	url : "/path",
	data : $('#signupForm').serialize(),// 你的formid
	async : false,
	cache : true,
	success : function(data) {
	}
});
  • ajax文件上传
<form enctype="multipart/form-data">

$.ajax({
	type : "POST",
	url : "/path",
	data : new FormData($('#signupForm')[0]),
	async : false,
	cache : false,
	dataType: 'JSON',
	contentType: false,
	processData: false,
	success : function(data) {
	}
});
  • FormData

for(let i in this.fileList){

          let file = this.fileList[i]
          formData.append("file", file.raw)
        }
      for (var [a, b] of formData.entries()) {
          console.log(a, b);
      }
  • select下拉框
选中值=e.target.value
选中文本=e.target.options[e.target.selectedIndex].text
web/form.txt · 最后更改: 2021/07/09 16:49 由 admin