【发布时间】:2018-02-13 06:29:03
【问题描述】:
在我发送数据的模板中使用 XMLHttpResponse。
我的代码如下:
...
<input type="button" value="ajax1" onclick="ajax1()">
<script>
function ajax1(){
var xhr = new XMLHttpRequest();
xhr.open('GET', '/ajax1/', true);
xhr.send("name=root;pwd=123"); // send data
}
</script>
但是我怎样才能在views.py接收数据呢?
在我的views.py:
def ajax1(request):
print request.GET.get('name'), request.GET.get('pwd') # all is None.
return HttpResponse('ajax1')
你看,我用request.GET.get(param_key)获取数据失败。
如何在我的views.py中获取XMLHttpResponse发送数据?
【问题讨论】:
标签: python django xmlhttprequest