From 0fc75a9ab5571942a86a37d4e900d5496cb49c31 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 12 Mar 2019 17:02:38 +0300 Subject: [PATCH] [common] ActiveXObject for XMLHttpRequest failed in IE11 for some requests --- apps/common/locale.js | 24 ++++++++------- apps/common/main/lib/util/utils.js | 48 ++++++++++++++++-------------- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/apps/common/locale.js b/apps/common/locale.js index 556ec30d6..40c9a5f20 100644 --- a/apps/common/locale.js +++ b/apps/common/locale.js @@ -39,20 +39,22 @@ Common.Locale = new(function() { var _createXMLHTTPObject = function() { var xmlhttp; - try { - xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); - } - catch (e) { + if (typeof XMLHttpRequest != 'undefined') { + xmlhttp = new XMLHttpRequest(); + } else { try { - xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); - } - catch (E) { - xmlhttp = false; + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } + catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } + catch (E) { + xmlhttp = false; + } } } - if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { - xmlhttp = new XMLHttpRequest(); - } + return xmlhttp; }; diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 8c16413c2..397fc45aa 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -634,20 +634,22 @@ Common.Utils.applyCustomizationPlugins = function(plugins) { var _createXMLHTTPObject = function() { var xmlhttp; - try { - xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); - } - catch (e) { - try { - xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); - } - catch (E) { - xmlhttp = false; - } - } - if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { + if (typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); + } else { + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } + catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } + catch (E) { + xmlhttp = false; + } + } } + return xmlhttp; }; @@ -690,17 +692,19 @@ Common.Utils.fillUserInfo = function(info, lang, defname) { Common.Utils.createXhr = function () { var xmlhttp; - try { - xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - try { - xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); - } catch (E) { - xmlhttp = false; - } - } - if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { + + if (typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); + } else { + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttp = false; + } + } } return xmlhttp;