Utilizing XMLHttpRequest in JavaScript to interact with Elasticsearch

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...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble with finding the correct object in an array of objects using indexOf and splice()?

Here is an example of an array of objects: "followers": [ { "id": "1be87842-2f7f-4e3b-8fde-9a998feb3a01", "bug_id": "4ae2707b-07ef-4e07-95da-77855c67fece", "user_id": "e9e81aa2-4994-483d-a3a7-3b88491f1fda", ...

Error: Invalid syntax detected: /blog

I am encountering an issue with jQuery while trying to add a blog section to my existing single-page site. The new blog will be located in a separate /blog directory, causing the menu item for it to differ from the other href="#" tags on the index.html pag ...

Adding data to a JSON object using AngularJS

When attempting to insert an object into a JSON object, I am encountering an issue where it duplicates the JSON object. Here is a breakdown of the scenario: <input type="text" style="width: 40% !important;" placeholder="Nom" class="input-sm" ng-model= ...

Organizing elements in a javascript array by their attributes using AngularJS

Picture this scenario: a collection of different wines: [ { "name":"wine A", "category":[ "red", "merlot" ] }, { "name":"wine B", "category":[ "white", "chardonnay" ...

The form does not display the radio button value upon submission

Using redux form for the form elements, I encountered an issue where the radio button values were not being displayed when submitting the form. Despite getting values for email and password fields, the role value from the radio buttons was missing. In my i ...

What is the best way to iterate over an array of objects using v-for in Vue.js?

Having trouble looping through this array of objects. Everything seems fine but the data is not showing up on the console. { "messages":[ { "id":1, "sender":"frank", "message":"Lorem ipsum...", "time":1398894261, "status":"read" } ...

Is the required attribute malfunctioning in HTML5?

I've come across some similar inquiries, but none of them address my specific question. I am working on a form where certain details are required, while others are optional. I have used the required tag for the mandatory fields. The submit button is l ...

Any methods for integrating js.erb files in Ruby on Rails 7?

I've been searching for a while now on how to integrate js.erb files into my Ruby On Rails 7 project, but I haven't been able to find any helpful information. Have js.erb files become obsolete in Rails 7? If so, is there a way to include partials ...

show an HTML webpage within a <div> container using AJAX technology

I am trying to include an HTML page named Introduction.html (located in the same folder as x.html) within div1. However, it does not seem to be loading properly. Below is a snippet of the code from x.html x.html <!DOCTYPE html> <h ...

Is the form always being processed by onsubmit and confirm?

Apologies if this question has been asked before. I am currently working on a form where I ask the user to confirm an action, but it's not functioning as expected. The form proceeds regardless of whether the user clicks ok, cancel, or even closes the ...

Emulating ArrowRight event using React Testing Library

I am facing a challenge with the React-Testing-Library. Within my application, I have two components called HeroesScreen and HeroesDiamondBar. The HeroesDiamondBar component is rendered inside the HeroesScreen component once the currentStep state variable ...

loop through nested arrays

My goal is to use ng repeat in Angular to iterate through a child array of a multidimensional array. The json object I am working with is as follows: $scope.items = [{ "id":1, "BasisA":"1", "Basis":true, "personSex": ...

Ways to access an element within a function triggered by an event listener

Is there a way to dynamically add a class to an element with a specific class when it is clicked? Specifically, I want to target elements with the "date" class and give them an additional class upon click. $(".date").on("click", function() { // Code t ...

Utilizing NodeJS on an alternative drive other than the system drive

Situation: On my Windows 8 x64 machine, I have NodeJS installed on the C drive. QUnit is also installed globally using the command npm install qunit -g. The issue at hand: When I try to reference QUnit by using var q = require('qunit'); while ...

javascript context scope

As I delve into the world of JavaScript, please bear with me as I navigate through defining multiple namespaces. Here's an example of how I'm doing it: var name_Class = function(){ this.variable_name_1 = {} this.method_name_1 = function() { ...

Make a request to the local API in a React Native mobile app by sending a GET request

Currently, I am working on a mobile application using React Native and utilizing SQL Server and NodeJS. The API for this project is located in my localhost. Upon running the application on an emulator, I encountered an issue when attempting to make a reque ...

What is the best method to trigger a form submission using Jquery?

Happy New Year! Wishing you a joyful 2015! I have a basic PHP contact form that I'm validating with Parsley.js. The validation is working well, but I'm receiving a high volume of spam emails. I think that if I make the form submission dependent ...

What is the proper way to utilize a filtered object based on its properties within an Angular controller?

Currently, I am working on developing a stacked graph along with its associated table. To retrieve the necessary JSON data, I am utilizing $http.get() and then assigning it to $scope.dataset. Here's a snippet of the HTML: <input ng-model="_search ...

RangeError: The React application has surpassed the maximum stack size limit, causing an error to be thrown

Hey there, I could use a hand. I'm fairly new to React and attempting to develop an application for managing contacts by adding them to Local Storage and deleting them. Below is the code snippet from my App.js file: import React, {useState, useEffect} ...

The dynamic pages specified by the graphql query in the gatsby-node.js file are not being generated by Gatsby.js as expected

Even after running gatsby clean followed by npm run develop, the issue persists... Several individuals familiar with the Gatsby framework have reviewed my gatsby-node.js file, but the problem remains puzzling... Below is a snippet of my gatsby-node.js fi ...