单击按钮后,我进行了 Jquery Ajax 发布调用,但在视图中它没有获取值。这是代码:
jQuery: -
$("#startSimulator").click(function(){
test = $("#testRange").val();
gameKey = ($('input:radio[name=radioGroup]:checked').val() || 0);
$("#imageLoading").css("display", "block");
$.post("/blackout/setup/",{d : d,test : test,gameKey : gameKey}, function(data){
$("#result").append(data);
});
});
网址.py:
urlpatterns = patterns('',
(r'^blackout/setup/$', 'blackout.views.setup'),
)
视图.py:
def setup(request):
gameKey = request.POST['gameKey']
test = request.POST['test']
data = request.POST['d']
#Some other code
#And then HttpResponse(data)
错误:-
Exception Value:
"Key 'gameKey' not found in <QueryDict: {}>"
/home/dhruv/blackout_new_project/blackout/blackout_proj/blackout/views.py in setup
gameKey = request.POST['gameKey']