Commit 52fb7455 authored by Wolfgang Knopki's avatar Wolfgang Knopki
Browse files

test dynamic header

No related merge requests found
Pipeline #122 passed with stage
in 3 seconds
Showing with 14 additions and 1 deletion
+14 -1
...@@ -22,10 +22,23 @@ function userAuthenticated(){ ...@@ -22,10 +22,23 @@ function userAuthenticated(){
} }
function readCookie(name) {
var nameEQ = encodeURIComponent(name) + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ')
c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0)
return decodeURIComponent(c.substring(nameEQ.length, c.length));
}
return null;
}
function sendRequest(URL){ function sendRequest(URL){
let xhr = new XMLHttpRequest(); let xhr = new XMLHttpRequest();
xhr.open("POST", URL, true); xhr.open("POST", URL, true);
let token = $("meta[name='_csrf']").attr("content"); let token = readCookie("XSRF-TOKEN");
//Send the proper header information along with the request //Send the proper header information along with the request
xhr.setRequestHeader('X-CSRF-TOKEN', token); xhr.setRequestHeader('X-CSRF-TOKEN', token);
xhr.send(); xhr.send();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment