1
在模板中我發送數據使用XMLHttpResponse。如何讓我的views.py中的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發送數據?