It seems there's some confusion here. XMLHttpRequest is a built-in object in browsers, used for making HTTP requests in JavaScript. It doesn't need to be imported like Java packages.
Your XMLHttpRequest code looks just fine for a simple synchronous GET request. But, I'd recommend using the Fetch API or async/await with XMLHttpRequest, for a more modern, asynchronous approach.
Also, the Java import statements you've provided are related to Apache OpenOffice's UNO API. If you're trying to use these with JavaScript, you might be mixing up languages and environments. Please clarify your requirement if this doesn't help!
I'm searching for a way to fetch JSON data from a website.
I find HttpUrlConnection but the sample is in Java: viewtopic.php?t=71712
I don't know how to translate this code
I only posted them as possible help for your question; I leave the decision as to whether they suit your needs to you. You made no previous reference to Rhino - whatever that may be.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers