Having trouble making a GET request to another website from work, but when attempting to request from Elasticsearch using localhost it is not working.
The status codes returned are:
Create Object from JSON String 4, 0,
readyState = 4 status = 0
Below is the Javascript code for the above result.
<!DOCTYPE html>
<html>
<body>
<h2>
Create Object from JSON String</h2>
<p id="demo">
</p>
<script>
var url = "http://127.0.0.1:9200/";
document.getElementById("demo").innerHTML = url;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
document.getElementById("demo").innerHTML = xmlhttp.readyState + ", " + xmlhttp.status + ", " + xmlhttp.responseText;
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var response = JSON.parse(xmlhttp.responseText);
document.getElementById("demo").innerHTML = myArr;
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
</script>
</body>
</html>
Having issues with localhost:9200 not working as well. Despite some suggestions that requesting by 'localhost' may cause browser issues, the questioner asserts that they have already done so. Therefore, I am left wondering what could be causing the problem...