以下是javascript代码:
$.ajax({
type: 'POST',
url: '/vote_selection/vote/',
dataType:'json',
data: {'message':'123'},
success:function(data){
alert(data);
}
});
下面是python代码:
def vote_select(request):
print "1"
print request
print request.method
print request.POST
return HttpResponse("1",mimetype='text/plain')
输出
1
, POST:, ... 'REQUEST_METHOD':'GET', ..
GET
[29 / Sep / 2012 22:38:49]“GET / vote_selection / vote / HTTP / 1.0”200 1
为什么该方法变为GET,为什么GET或POST中没有params?
谢谢!
答案 0 :(得分:0)
试试这个:
import json
def vote_select(request):
print "1"
print request
print request.method
print request.POST
return HttpResponse(json.dumps({ 'somevalue': 1 }),mimetype='application/json')