From 18276b4f4bbfa094d76d121eed6ed80e7e022586 Mon Sep 17 00:00:00 2001 From: Timon Engelke Date: Tue, 30 Mar 2021 12:19:18 +0200 Subject: [PATCH] make loadAnnotationTypeList async --- .../static/annotations/js/annotations.js | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/imagetagger/imagetagger/annotations/static/annotations/js/annotations.js b/imagetagger/imagetagger/annotations/static/annotations/js/annotations.js index f877b70d..50e5525d 100644 --- a/imagetagger/imagetagger/annotations/static/annotations/js/annotations.js +++ b/imagetagger/imagetagger/annotations/static/annotations/js/annotations.js @@ -249,18 +249,17 @@ function calculateImageScale() { } } - function loadAnnotationTypeList() { - $.ajax(API_ANNOTATIONS_BASE_URL + 'annotation/loadannotationtypes/', { - type: 'GET', - headers: gHeaders, - dataType: 'json', - success: function (data) { - displayAnnotationTypeOptions(data.annotation_types); - }, - error: function () { - displayFeedback($('#feedback_connection_error')) - } - }) + async function loadAnnotationTypeList() { + try { + let response = await fetch(API_ANNOTATIONS_BASE_URL + 'annotation/loadannotationtypes/', { + method: 'GET', + headers: gHeaders, + }); + let data = await response.json(); + displayAnnotationTypeOptions(data.annotation_types); + } catch { + displayFeedback($('#feedback_connection_error')) + } } function displayAnnotationTypeOptions(annotationTypeList) {