“Token CSRF di JS” Kode Jawaban

cara mendapatkan token csrf di javascript

<input type="hidden" name="csrftoken" value="hgdillksdbgjksdbkvbskb">
Worrisome Wren

Token CSRF di JS

You are not sending the server generated csrf_token for the POST to verify the validity of the data. Hence the error.

As a part of the data part of the request, you need to send the token

csrfmiddlewaretoken: '{{ csrf_token }}' 
Something like this

var data = {
    url: item.find("#id_url").val(),
    title: item.find("#id_title").val(),
    tags: item.find("#id_tags").val(),
    csrfmiddlewaretoken: '{{ csrf_token }}' 
};

Or you could simply do:

var data = $('form').serialize()
if you want to send the whole form as a dictionary
Frantic Flatworm

cara mendapatkan token csrf di javascript

csrftoken = document.mainform.csrftoken.value;
# Do something with the CSRF token, like add dynamic values, like sha256(csrftoken + "dynamicvalue");
document.mainform.csrftoken.value = csrftoken;
Worrisome Wren

Token CSRF di JS

 <input type="checkbox" class="item-check" name="ssns[]" value="15745253">
Relieved Raven

Token CSRF di JS

<input type="hidden" name="_token" value="GmUW4QXFvoTn3VlXVbQ90N9UGDxohuC1TTwYMzV2">
Relieved Raven

Token CSRF di JS

 <input type="checkbox" class="item-check" name="ssns[]" value="15745253">
Relieved Raven

Jawaban yang mirip dengan “Token CSRF di JS”

Pertanyaan yang mirip dengan “Token CSRF di JS”

Lebih banyak jawaban terkait untuk “Token CSRF di JS” di HTML

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya