这是我的js代码:
function sendMP3ViaAJAX(MP3File) {
console.log(MP3File.name); //file is present, as I can get its name
$.ajax({type: "POST",
url: "saveMP3",
enctype: 'multipart/form-data',
processData: false,
data: {'mp3File': MP3File},
success: function (text)
{
response = text;
},
complete: function () {
$("#retourAJAX").html("blah blah");
}
});
}
但如果我调试我的项目
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Part part = request.getPart("MP3FILE"); //request.parts is null...
(常量CHAMP_FICHIER
等于AJAX调用中定义的那个,即mp3File
...)你知道缺少什么吗?由于我已经在页面上动态加载了内容,因此我不希望发生默认的HTML POST提交行为...