【发布时间】:2021-04-25 13:54:51
【问题描述】:
假设我的 django 项目中有以下功能。 getValues2() 返回一个带有数字的列表。如何使用 window.location 将此数字传递给我的视图?
<script>
let getValues2 = () => $("input[name='checkb']:checked").map((i,el) => el.id.trim()).get();
console.log('getValues2 ',getValues2())
window.location('eprint/checked' + getValues?()
</script>
views.py
def eprint(request):
print('eprint')
# how to get the list from jquery?
print(checked)
【问题讨论】:
-
您必须从 js 到 django 中的特定 url 进行 AJAX 调用才能在视图中接收。
-
尝试上述方法时出现此错误:window.location 不是函数