From 4e9cc522bbab6ef69307743d0bafb28cbab398cc Mon Sep 17 00:00:00 2001 From: Tim Jacomb <21194782+timja@users.noreply.github.com> Date: Tue, 4 Apr 2023 16:23:21 +0100 Subject: [PATCH] [JENKINS-70912] Remove `Ajax.Request` from `build-timeline-widget` (#7731) --- .../build-timeline-widget.js | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/core/src/main/resources/hudson/model/BuildTimelineWidget/build-timeline-widget.js b/core/src/main/resources/hudson/model/BuildTimelineWidget/build-timeline-widget.js index 6d4795ba65..4437c99d13 100644 --- a/core/src/main/resources/hudson/model/BuildTimelineWidget/build-timeline-widget.js +++ b/core/src/main/resources/hudson/model/BuildTimelineWidget/build-timeline-widget.js @@ -11,19 +11,27 @@ function getData(eventSource1, current, min, max) { } if (!eventSource1.loaded[current]) { eventSource1.loaded[current] = true; - new Ajax.Request("timeline/data/", { - method: "POST", - parameters: { min: current * interval, max: (current + 1) * interval }, - onSuccess: function (t) { - if (t.status != 0) { - try { - eventSource1.loadJSON(JSON.parse(t.responseText), "."); + fetch( + "timeline/data/?" + + new URLSearchParams({ + min: current * interval, + max: (current + 1) * interval, + }), + { + method: "POST", + headers: crumb.wrap({}), + } + ).then((t) => { + if (t.ok) { + t.json() + .then((json) => { + eventSource1.loadJSON(json, "."); getData(eventSource1, current - 1, min, max); - } catch (e) { - alert(e); - } - } - }, + }) + .catch((err) => { + alert(err); + }); + } }); } }