【发布时间】:2014-12-18 18:46:33
【问题描述】:
我想在 django 中使用 ajax 将文件和注释保存在后端。对于文件,我遇到了麻烦。 如何将文件发送到后端。 我要查看的笔记 但我无法发送文件以供查看。
<form class="horizontal-form" role="form" action="." method="post" enctype="multipart/form-data" id="nofilesforms">
<input type="file" name="image_file" id="image_file_data">
<textarea class="form-control notesdata" data-stylesheet-url="" name="notes"></textarea>
<button class="btn btn-primary" id="filesandnotes" type="button">Submit</button>
</form>
$(document).on('click','#filesandnotes',function(){
var notes = $('.notesdata').val();
var path = $('input[type=file][name=image_file]').val();
alert(path);
var data = {
notes:notes,
path:path
};
$.ajax({
url:"/cbs/msw1/",
type: "POST",
data: data,
success: function (response) {
},
error: function () {
}
});
});
请任何人都可以指导我。 非常感谢
【问题讨论】:
-
"我正在进入后端" 这到底是什么意思?此外,您应该提供有关您已经对代码进行的诊断的更多信息。否则,这是一个“寻找错误”的问题。