From 234b9aa67a8ba16d30cdaaac6aeb35562e0d7353 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 16 Dec 2016 18:41:10 +1300 Subject: Keep service session cookie --- web/simple/app.js | 15 ++++++++------- web/simple/index.html | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'web') diff --git a/web/simple/app.js b/web/simple/app.js index 19c4de59..5ae8ac2c 100644 --- a/web/simple/app.js +++ b/web/simple/app.js @@ -51,17 +51,18 @@ var map = new ol.Map({ }); var ajax = function (method, url, callback) { - var x = new XMLHttpRequest(); - x.open(method, url, true); - x.onreadystatechange = function () { - if (x.readyState == 4) { - callback(JSON.parse(x.responseText)); + var xhr = new XMLHttpRequest(); + xhr.withCredentials = true; + xhr.open(method, url, true); + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { + callback(JSON.parse(xhr.responseText)); } }; if (method == 'POST') { - x.setRequestHeader('Content-type', 'application/json'); + xhr.setRequestHeader('Content-type', 'application/json'); } - x.send() + xhr.send() }; ajax('GET', url + '/api/session?token=' + token, function(user) { diff --git a/web/simple/index.html b/web/simple/index.html index 08c9b2bb..d4bfe504 100644 --- a/web/simple/index.html +++ b/web/simple/index.html @@ -4,11 +4,11 @@ Traccar - +
- + -- cgit v1.2.3