I have a problem with the xhr open () method. My code is:
var xmlhttp=false;
if(!xmlhttp)
try
{
xmlhttp=new XMLHttpRequest();
}
catch(e)
{
xmlhttp=false;
}
function returnPage(url)
{
if(!xmlhttp)
return alert("Your browser doesn't seem to support XMLHttpRequests.");
xmlhttp.open("GET",url,true);
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState!=4) return;
if(!xmlhttp.status||xmlhttp.status==200)
alert(xmlhttp.responseText);
else
alert("Request failed!");
};
xmlhttp.send(null);
}
Call:
<a href='#' onclick="returnPage('http://www.something.com'); return false;">Link 1</a></p>
I am using IE8 (because I am building a web fragment) and I received the "Access denied" error message. I found on the Internet that the problem is that XHR does not work in different domains, but I used the code from the Firefox add-on, which works fine. Both this additional code and the “my” code (the same) invoke the same page. How does this add-on have access, but my code does not work?
source
share