File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ request.open("POST", "submitform.php");
21
21
request .send (new FormData (formElement));
22
22
```
23
23
* 创建FormData对象
24
+
24
25
``` js
25
26
var formData = new FormData ();
26
27
@@ -43,7 +44,9 @@ request.send(formData);
43
44
44
45
> (FormData 对象的字段类型可以是 Blob, File, 或者 string: 如果它的字段类型不是Blob也不是File,则会被转换成字符串类型。
45
46
47
+
46
48
# JQuery form回调函数提交
49
+
47
50
``` js
48
51
// 不带文件上传的form回调提交
49
52
$ (" #ajaxform" ).submit (function (e )
@@ -101,8 +104,6 @@ $("#multiform").submit(); //Submit the form
101
104
```
102
105
# JQuery FormData对象上传文件
103
106
104
- * HTML表单FormData初始化
105
-
106
107
``` js
107
108
$ .ajax ({
108
109
url: ' php/upload.php' ,
@@ -116,12 +117,13 @@ $.ajax({
116
117
}
117
118
});
118
119
```
120
+
119
121
> ** 注意**
120
122
> * contentType:false* //强制JQuery不添加Content-Type头部,否则文件上传的分割线(boundary string)將丢失;
121
123
> * processData: false * //如果设置为true JQuery则会將内容转换为string,这是错误的
122
124
123
125
124
- 相关链接:
126
+ 相关链接:
125
127
[ https://developer.mozilla.org/zh-CN/docs/Web/API/FormData/Using_FormData_Objects ] ( https://developer.mozilla.org/zh-CN/docs/Web/API/FormData/Using_FormData_Objects )
126
128
127
129
[ https://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax ] ( https://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax )
You can’t perform that action at this time.
0 commit comments