diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-12-16 18:41:10 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-12-16 18:41:10 +1300 |
commit | 234b9aa67a8ba16d30cdaaac6aeb35562e0d7353 (patch) | |
tree | 0305c955ef5f2c23ccff34ca2898ad170a343b75 /web/simple/app.js | |
parent | 37d91fdce003cc0e82bc6c3c1f7ee64c63fde1f8 (diff) | |
download | trackermap-web-234b9aa67a8ba16d30cdaaac6aeb35562e0d7353.tar.gz trackermap-web-234b9aa67a8ba16d30cdaaac6aeb35562e0d7353.tar.bz2 trackermap-web-234b9aa67a8ba16d30cdaaac6aeb35562e0d7353.zip |
Keep service session cookie
Diffstat (limited to 'web/simple/app.js')
-rw-r--r-- | web/simple/app.js | 15 |
1 files changed, 8 insertions, 7 deletions
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) { |