Skip to content

Commit 47cec07

Browse files
author
zhaoliang
committed
格式修改
1 parent ca5b5f3 commit 47cec07

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

_posts/js/2017-06-23-ajax_form_submit.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ request.open("POST", "submitform.php");
2121
request.send(new FormData(formElement));
2222
```
2323
* 创建FormData对象
24+
2425
```js
2526
var formData = new FormData();
2627

@@ -43,7 +44,9 @@ request.send(formData);
4344

4445
> (FormData 对象的字段类型可以是 Blob, File, 或者 string: 如果它的字段类型不是Blob也不是File,则会被转换成字符串类型。
4546
47+
4648
# JQuery form回调函数提交
49+
4750
```js
4851
// 不带文件上传的form回调提交
4952
$("#ajaxform").submit(function(e)
@@ -101,8 +104,6 @@ $("#multiform").submit(); //Submit the form
101104
```
102105
# JQuery FormData对象上传文件
103106

104-
* HTML表单FormData初始化
105-
106107
```js
107108
$.ajax({
108109
url: 'php/upload.php',
@@ -116,12 +117,13 @@ $.ajax({
116117
}
117118
});
118119
```
120+
119121
> **注意**
120122
> *contentType:false* //强制JQuery不添加Content-Type头部,否则文件上传的分割线(boundary string)將丢失;
121123
> *processData:false* //如果设置为true JQuery则会將内容转换为string,这是错误的
122124
123125

124-
相关链接:
126+
相关链接:
125127
[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)
126128

127129
[https://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax](https://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax)

0 commit comments

Comments
 (0)