0

下面是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', ..

得到

[29/Sep/2012 22:38:49]“GET /vote_selection/vote/HTTP/1.0”200 1

为什么方法会变成 GET,为什么 GET 或 POST 中都没有参数?

谢谢!

4

1 回答 1

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')
于 2012-09-30T06:45:38.880 回答