1

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!

jsalonen
  • 29,593
  • 15
  • 91
  • 109
Alex Gonzalez
  • 981
  • 1
  • 11
  • 17

1 Answers1

0

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?

Mirat Can Bayrak
  • 631
  • 7
  • 18