diff --git a/scripts/pi-hole/js/debug.js b/scripts/pi-hole/js/debug.js index 0af41f751..501aad138 100644 --- a/scripts/pi-hole/js/debug.js +++ b/scripts/pi-hole/js/debug.js @@ -5,31 +5,6 @@ * This file is copyright under the latest version of the EUPL. * Please see LICENSE file for your rights under this license. */ -/* global ActiveXObject: false */ - -// Credit: http://stackoverflow.com/a/10642418/2087442 -function httpGet(ta, theUrl) { - var xmlhttp; - if (window.XMLHttpRequest) { - // code for IE7+ - xmlhttp = new XMLHttpRequest(); - } else { - // code for IE6, IE5 - xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); - } - - xmlhttp.onreadystatechange = function () { - if (xmlhttp.readyState === 4 && xmlhttp.status === 200) { - ta.show(); - ta.empty(); - ta.append(xmlhttp.responseText); - } - }; - - xmlhttp.open("GET", theUrl, false); - xmlhttp.send(); -} - function eventsource() { var ta = $("#output"); var upload = $("#upload"); @@ -42,7 +17,15 @@ function eventsource() { // IE does not support EventSource - load whole content at once if (typeof EventSource !== "function") { - httpGet(ta, "scripts/pi-hole/php/debug.php?IE&token=" + token + "&" + checked); + $.ajax({ + method: "GET", + url: "scripts/pi-hole/php/debug.php?IE&token=" + token + "&" + checked, + async: false + }).done(function (data) { + ta.show(); + ta.empty(); + ta.append(data); + }); return; } diff --git a/scripts/pi-hole/js/queryads.js b/scripts/pi-hole/js/queryads.js index 285560230..2c2db3135 100644 --- a/scripts/pi-hole/js/queryads.js +++ b/scripts/pi-hole/js/queryads.js @@ -5,8 +5,6 @@ * This file is copyright under the latest version of the EUPL. * Please see LICENSE file for your rights under this license. */ -/* global ActiveXObject: false */ - var exact = ""; function quietfilter(ta, data) { @@ -21,33 +19,6 @@ function quietfilter(ta, data) { } } -// Credit: http://stackoverflow.com/a/10642418/2087442 -function httpGet(ta, quiet, theUrl) { - var xmlhttp; - if (window.XMLHttpRequest) { - // code for IE7+ - xmlhttp = new XMLHttpRequest(); - } else { - // code for IE6, IE5 - xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); - } - - xmlhttp.onreadystatechange = function () { - if (xmlhttp.readyState === 4 && xmlhttp.status === 200) { - ta.show(); - ta.empty(); - if (!quiet) { - ta.append(xmlhttp.responseText); - } else { - quietfilter(ta, xmlhttp.responseText); - } - } - }; - - xmlhttp.open("GET", theUrl, false); - xmlhttp.send(); -} - function eventsource() { var ta = $("#output"); var domain = $("#domain").val().trim(); @@ -65,11 +36,19 @@ function eventsource() { // IE does not support EventSource - load whole content at once if (typeof EventSource !== "function") { - httpGet( - ta, - quiet, - "scripts/pi-hole/php/queryads.php?domain=" + domain.toLowerCase() + exact + "&IE" - ); + $.ajax({ + method: "GET", + url: "scripts/pi-hole/php/queryads.php?domain=" + domain.toLowerCase() + exact + "&IE", + async: false + }).done(function (data) { + ta.show(); + ta.empty(); + if (!quiet) { + ta.append(data); + } else { + quietfilter(ta, data); + } + }); return; }