XMLHttpRequest open() returning access denied
- by rjovic
Hi! I have problem with xhr open() method. My code follows :
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!");
}; //onreadystatechange
xmlhttp.send(null);
}
Call :
<a href='#' onclick="returnPage('http://www.something.com'); return false;">Link 1</a></p>
I'm using IE8 (because I'm building web slice) and I received error "Access denied". I found on the Internet that problem is that XHR isn't working across different domains, but I used code from Firefox Add-on which is working OK. And that add-on and "my" code (which are the same) are calling the same page. How that add-on have access and my code not?