SOLVED ?, almost ..
This is due to how Chrome (47.0.2526.73) handles xml files. I don't know the details, but this code works fine in Firefox (43.0.4).
I'm still wondering why this is, or how to make it work in Chrome.
What am I trying to do:
Create a javascript bookmarklet to check sitemap xml links for 404s / 500s / etc.
Labeled code snippet:
var siteMap="http://www.example.com/sitemap.xml";
var httpPoke = function(url,callback){
var x;
x = new XMLHttpRequest();
x.open('HEAD', url);
x.onreadystatechange = function() {
if (this.readyState == this.DONE) {
callback(this.status);
}
}
x.send();
};
var response=httpPoke(siteMap,function(n){
console.log(n);
});
If I am on any other page in the domain, the answer is:
200
If I go to the actual site map, http://www.example.com/sitemap.xml , the same code answers:
"Access-Control-Allow-Origin" . "null" .
- , , .
:
1) xml -. Google "filetype: xml sitemap" , XML ( , ).
2) .
3) , siteMap URL. CORS. siteMap = location.href;
, , Firefox, Chrome.
:
FROM HTML, HTML- .
FROM HTML-, XML-, .
FROM XML, HTML-, .
FROM XML, XML-, .
, :
, , () :
, .