【发布时间】:2018-11-19 08:30:56
【问题描述】:
我在我的 django 项目中使用 promise 收到了一个 Ajax 请求:
var path = window.location.pathname;
fetch('/getblogs/', {
method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({'path': path})
}).then(function (response) {
return response.json();
});
请求在js 文件中,并且没有表单。
我正在尝试像这样读取views.py 中的数据:
@csrf_exempt
def get_blogs(request):
cat_id = request.POST.get('path')
print("RESULT: " + str(cat_id))
但在输出中我得到:
RESULT: None
是我在阅读帖子数据时遗漏了什么,还是我的 ajax 请求有问题?
【问题讨论】:
标签: python ajax django es6-promise