The mistake Status Code 401
happens when you make a request, but you are not allowed.
Already the error cited in the comment of the previous reply:
"Failed to load infomoney.com.br/blogs/investimentos/off-the-records/rss: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost'; is therefore not allowed access."
It happens due to lack of header Access-Control-Allow-Origin
on the server response.
To get around this, you can use the site https://cors.io/
. It will serve as an intermediary and will automatically add the header necessary.
Example with Fetch:
fetch("https://cors.io/?http://www.infomoney.com.br/blogs/investimentos/off-the-records/rss")
.then( resp => resp.text() )
.then(resp => console.log(resp))
.catch( err => console.debug(err) );
Example with XHR:
var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(ajax.responseText);
}
};
ajax.open("GET", "https://cors.io/?http://www.infomoney.com.br/blogs/investimentos/off-the-records/rss", true);
ajax.send();
I implemented the following error "ailed to load http://www.infomoney.com.br/blogs/investiments/off-the-records/rss: No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://localhost' is therefore not allowed access. ajaxvs1.html:28 Failed to send AJAX"
– Rafael Luz
I’ll edit the answer, there’s a few things missing
– gabrielfalieri
Now appears following error; "Uncaught Referenceerror: form is not defined"
– Rafael Luz
just take out of the data:form... you are not sending anything
– Leandro Angelo
It worked my dear?
– gabrielfalieri
No.Shows the same error as before "Failed to load http://www.infomoney.com.br/blogs/investiments/off-the-records/rss: No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://localhost' is therefore not allowed access."
– Rafael Luz
You already have somewhere to lodge it?
– gabrielfalieri
My return here was right
– gabrielfalieri
If your problem has been solved please check as Solved. It may be useful for others with the same problem
– gabrielfalieri