Skip to content

Commit a8a54bd

Browse files
committed
upload
1 parent ac91cb6 commit a8a54bd

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

static/js/bookstack.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -140,27 +140,6 @@ function pre_and_next_link(){
140140
}
141141
}
142142

143-
// 上传文件
144-
function upload(url, formData, callback){
145-
// var formData = new FormData();
146-
// formData.append('xxx name', 'xxx value')
147-
$.ajax({
148-
type: "POST",
149-
url: url,
150-
data: formData ,  //这里上传的数据使用了formData 对象
151-
processData : false,
152-
//必须false才会自动加上正确的Content-Type
153-
contentType : false ,
154-
//这里我们先拿到jQuery产生的 XMLHttpRequest对象,为其增加 progress 事件绑定,然后再返回交给ajax使用
155-
success:function (res) {
156-
callback(res)
157-
},
158-
error:function (e) {
159-
callback(e)
160-
}
161-
});
162-
}
163-
164143
$(function () {
165144
$(".article-menu-detail>ul>li a").tooltip({placement: 'bottom'})
166145
$(".view-backtop").on("click", function () {

static/js/main.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,27 @@ function alertTips(cls,msg,timeout,url) {
8282
},parseInt(timeout));
8383
}
8484

85+
// 上传文件
86+
function upload(url, formData, callback){
87+
// var formData = new FormData();
88+
// formData.append('xxx name', 'xxx value')
89+
$.ajax({
90+
type: "POST",
91+
url: url,
92+
data: formData ,  //这里上传的数据使用了formData 对象
93+
processData : false,
94+
//必须false才会自动加上正确的Content-Type
95+
contentType : false ,
96+
//这里我们先拿到jQuery产生的 XMLHttpRequest对象,为其增加 progress 事件绑定,然后再返回交给ajax使用
97+
success:function (res) {
98+
callback(res)
99+
},
100+
error:function (e) {
101+
callback(e)
102+
}
103+
});
104+
}
105+
85106
$(function () {
86107
$(".tooltips").tooltip();
87108

0 commit comments

Comments
 (0)