1

I am accessing https://example.com/about/edit (Domain changed for privacy reasons) from my browser. There, I have JavaScript code running that is sending a HTTP request to https://example.com/about/api/id with an identifier for an object on my server.

let xhr = new XMLHttpRequest();
xhr.open("GET", "https://example.com/api/"+id, true)
xhr.send(null)
console.log(xhr.responseText) // <empty string>

The interesting thing is that xhr.responseText is empty, though I can see it in my Firefox network tab and also the request is from the same origin.

Photo from firefox

Help would be very much appreciated!

Karl Heinz
  • 11
  • 1
  • 1
    As you code do not wait for the response, Take a glance this will help you, [Get Response By XMLHttpRequest](https://stackoverflow.com/questions/3038901/how-to-get-the-response-of-xmlhttprequest) – Sakil Aug 27 '22 at 20:16

0 Answers0