From 6a9ff124a5b30ad2e7a8244e950516d6003903f4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 20 Feb 2024 10:00:11 +0100 Subject: [PATCH] Bug 36084: Fix is_ajax by setting X-Requested-With header Some svc scripts (and controllers) are using using is_ajax to guess if it's an AJAX request. $.ajax is setting the (non standard) X-Requested-With header, but the low level JS 'fetch' does not. This patch set it in http-client. Signed-off-by: Jonathan Druart --- koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js index 83c8d078b9..c542858f11 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js @@ -17,8 +17,9 @@ class Dialog { class HttpClient { constructor(options = {}) { this._baseURL = options.baseURL || ""; - this._headers = options.headers || { + this._headers = options.headers || { // FIXME we actually need to merge the headers "Content-Type": "application/json;charset=utf-8", + "X-Requested-With": "XMLHttpRequest" }; this.csrf_token = $('meta[name="csrf-token"]').attr("content"); } -- 2.39.5