How send data from client Javascript to Django server?
I tried the following but it didn't work. I want to read "token" cookie
value
and send to server but it never receives it as a valid form. Any sample
working code greatly appreciated.
<script>
function start_processing() {
path = document.getElementById("path_inp").value;
token = "";
csrf = ""
kvps = document.cookie.split(";");
for(i = 0; i < kvps.length; i++) {
if (kvps[i].split("=")[0].trim() == "token") {
token = kvps[i].split("=")[1].trim();
}
if (kvps[i].split("=")[0].trim() == "csrftoken") {
csrf = kvps[i].split("=")[1].trim();
}
}
alert(path + " " + token + " " + csrf);
$.post("/extraction",
{"path" : path, "token" : token, "csrftoken" :
csrf});
}
</script>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/22bad142-aae0-4cfd-a2b2-7f8e2126b65dn%40googlegroups.com.