使用formdata上传数据
$(function() {
fileStack=[];//总的上传图片栈
//上传事件
$("#uploadBtn").on("click", function() {
var desc=['222','222'];
var formdata = new FormData();
$.each(fileStack,function(i,file){
formdata.append("files",file);
});
formdata.append("title","我是标题");
$.ajax({
url : "test",
type : 'POST',
dataType: 'json',
data : formdata,
cache: false,
processData: false,
contentType: false,
success : function(responseStr) {
alert("成功");
},
error : function(responseStr) {
alert("失败");
}
});
});
});
注意processData,contentType的含义及应用 true false