adding timeout to backend ajax

This commit is contained in:
Kristjan Komlosi
2019-11-01 19:31:21 +01:00
parent 537183078f
commit 8f8ef9753f

View File

@@ -6,17 +6,16 @@ $('#update').click(function () {
// jQuery event binder // jQuery event binder
function updateData () { function updateData () {
// download data from backend into obj
const url = 'http://' + window.location.hostname + ':5000/data'; const url = 'http://' + window.location.hostname + ':5000/data';
// I understand how bad this line looks. Please don't judge me... $.ajax({ // spawn an AJAX request
$.get(url, function (data, status) { // standard jQuery AJAX url: url,
globalObject = data; success: function (data, status) { globalObject = data; },
}) timeout: 2500 // this should be a pretty sane timeout
.done(function () { }).done(function () {
fillTable(globalObject, $('#specter')); fillTable(globalObject, $('#specter'));
graphSpectralData(globalObject, $('#spectrogram')); graphSpectralData(globalObject, $('#spectrogram'));
fillLuxUv(globalObject, $('#luxuv')); fillLuxUv(globalObject, $('#luxuv'));
}); });
} }
function fillTable (obj, dom) { function fillTable (obj, dom) {