下面的data:..
行是正确的吗?我想将表单数据和 csrf 令牌发布到 Django 视图函数。
$('#file-upload').on('change', function () {
var currentpath = window.location.pathname;
var formData = new FormData($('form')[0]);
$.ajax({
url: currentpath, //server script to process data
type: 'POST',
data: {formData, 'csrfmiddlewaretoken': '{{ csrf_token }}'},
cache: false,
contentType: false,
processData: false
});
});