Replace custom httpGet() with $.ajax()" (#1371)

Signed-off-by: Paul Mannarino <paul.mannarino@gmail.com>
This commit is contained in:
Paul Mannarino
2020-05-25 14:59:18 -04:00
committed by GitHub
parent c86515e028
commit 256aff73a6
2 changed files with 22 additions and 60 deletions

View File

@@ -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;
}