XMLHttpRequest open() returning access denied

Posted by rjovic on Stack Overflow See other posts from Stack Overflow or by rjovic
Published on 2010-04-25T15:46:50Z Indexed on 2010/04/25 15:53 UTC
Read the original article Hit count: 320

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about xmlhttprequest

Related posts about ie8