I have a Django site using a 5-star rating system for voting (I use django-ratings) and I would like to store the votings of the users with AJAX calls.
On the client side I have a JavaScript function sending a GET request to a URL:
$.ajax({
url: url,
success: function(data) {
alert('Load was performed.');
}
});
On the server side I have code setting the cookie:
def vote(request, slug, rating):
# Some irrelevant code...
response = HttpResponse('Vote changed.')
response.set_cookie('vote', 123456)
return response
The problem is that the cookie is never set in the browser.
What I am doing wrong?
Thanks!
Are sure that your problem is about Cross-site request forgery protection? most ajax requests rejected django by that. Don't you have any error messages?