【发布时间】:2021-02-07 21:43:06
【问题描述】:
我只写了需要的东西。我是新手,所以请忽略问题质量:)。
我的 HTML ---
<div class="form-group row pt-3 d-flex justify-content-center">
<div class="col-sm-10 d-flex justify-content-center">
<button id="submit_pic" style="width: 70%;" type=""
class="btn btn-primary">Combine</button>
<script>
$("#submit_pic").submit(function (e) {
e.preventDefault();
var csrfToken = $("input[name='csrfmiddlewaretoken']");
$.ajax({
url: "{% url 'make_combine' %}",
//url: "/make_combine",
type: "POST", //-------here is problem-------
dataType: "json",
cache: true,
headers: {'csrfmiddlewaretoken': csrfToken.val()},
data: {"for_combine": response_send },
//"success": function (result) {
// console.log(data);
//},
});
return false;
});
</script>
</div>
</div>
django views.py --
import json
def make_combine(request):
combine_data7 = request.POST.get("for_combine")
我在互联网和 StackOverflow 上尝试了很多可用的技巧,但仍然收到此错误。它表明 combine_data7 是 NoneType ----
AttributeError at /make_combine
'NoneType' object has no attribute 'split'
谢谢妈妈/先生。
【问题讨论】:
-
这里的
response_send是什么?它有什么价值吗? -
是的,它有价值。我已经通过 console.log(response_send) 检查了它。它具有base64图像的价值。
标签: django ajax nonetype postdata