【发布时间】:2013-02-03 23:00:09
【问题描述】:
$.ajax({
type :'GET',
url : geturl(a),
// type: $(this).attr('method'),
dataType : 'json',
views.py:
if request.method=="POST":
if request.POST.get('monyrsubmit'):
monthform=MonthForm(request.POST)
if monthform.is_valid():
selected_month=monthform.cleaned_data["Month"]
selected_year=monthform.cleaned_data["Year"]
print selected_month
print selected_year
我可以在 ajax 的类型字段中同时包含 GET 和 POST 请求吗?我使用表单并且仅当单击提交按钮时我试图根据提交的数据显示信息。如果 request.POST.get('monyrsubmit') 不起作用。 帮助将不胜感激
【问题讨论】:
-
想必您已经在 AJAX 部分中使用
type: 'POST'尝试过?您在 Firebug 或 Chrome Inspector 网络面板中看到了什么?我最好的猜测是你正在攻击 Django 的 CSRF 保护。
标签: django