continue
I'm trying to use an ajax request to call a function in a different view, but I'm getting a 403 error.
excerpt from my template:
FB.ui({ method: 'apprequests', title: 'Invite your friends to answer questions!', message:'Invite your friends!'},
function(response) {
jQuery.ajax({
url: "/canvas/request/",
type: "post",
data: {qid: {{ qid }} , request_ids: response.request_ids}
})
});
excerpt from my view:
def save_request(request):
print("in save request")
for id in request.request_ids:
share = ShareRequest
share.question = request.qid
share.share_id = id
share.save()
excerpt from my urls:
urlpatterns = patterns(...
(r'^request/', save_request),
returns [06/Sep/2011 13:35:56] "POST /canvas/request/ HTTP/1.1" 403 2332
I'm really confused.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Perhaps you need to add the CSRF token to your request? Some details are at https://docs.djangoproject.com/en/dev/ref/contrib/csrf/.
BAD but QUICK solution for keep yourself not in the stealth mode:
use this
@csrf_exempt
decorator at your views to ignore the csrf issue.但这是一个坏习惯。因此,请确保您的网站
csrf
受到保护。 And follow the django documentation.BAD but QUICK solution for keep yourself not in the stealth mode:
use this
@csrf_exempt
decorator at your views to ignore the csrf issue.But This is a bad habbit. So make sure your sites
csrf
protected. And follow the django documentation.