I'm using django restframe work,When I use browser to sent PUT request, it works well.but When I using ajax sent request just like before, it tell me csrf token is missing or incorrected.
My jQuery code looks like this:
$.ajax({
url: "/api/users/1/",
type: "PUT",
datatype: "json",
data: {csrfmiddlewaretoken: csrf_token, "user_gender": 2, "user_details": 23 },
....
In chrome console
csrfmiddlewaretoken:wUlPIaEmZd2FMA2ob9VRSVKWpOf6EQHn
user_gender:0
user_details:111asdfasdfsdf
I'd console.log(csrf_token), and it is as same as which I using in brower.
I followed Bryan here Django CSRF check failing with an Ajax POST request and it works in other page using POST request.