From 85d7be411741d0a2710d075d5f71fa4a6ec609c3 Mon Sep 17 00:00:00 2001 From: Kristjan Komlosi Date: Tue, 14 Jul 2020 10:37:57 +0200 Subject: [PATCH] refactor updateData to use simpler $.get method --- terahz/static/frontend.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/terahz/static/frontend.js b/terahz/static/frontend.js index 5341c38..e06b911 100644 --- a/terahz/static/frontend.js +++ b/terahz/static/frontend.js @@ -3,15 +3,12 @@ $('#update').click(updateData); // jQuery event binder function updateData () { - const url = 'http://' + window.location.hostname + ':5000/data'; - $.ajax({ // spawn an AJAX request - url: url, - success: function (data, status) { - console.log(data); +const url = '/data'; + $.get(url, (data, status) => { + if (status === '200') { graphSpectralData(data[0], 0); fillTableData(data); - }, - timeout: 2500 // this should be a pretty sane timeout + } else alert('Data request failed, please refresh page.'); }); }