Currently, I am aiming to retrieve the content of a text file using JavaScript for parsing purposes. Although I previously relied on jQuery and JSONP for this task, I now prefer to achieve it without any framework.
Despite numerous attempts, none have been successful so far. Here is my latest attempt:
var url = 'https://url.com/videosList.txt';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = process;
xhr.open("GET", url, true);
xhr.send();
function process()
{
if (xhr.readyState == 4) {
console.log(xhr.responseText);
}
}
The code appears to be correct, but my Chromium browser consistently presents the following error message:
> XMLHttpRequest cannot load
> https://url.com/videosList.txt. Origin
> http://localhost:8888 is not allowed by Access-Control-Allow-Origin.