xmlHTTPRequest Access is denied

I get the error "Access is Denied" when I try to call the first line in the following lines of code:

xmlhttp.open("GET","myrealurl.com",true);
xmlhttp.send("");
xmlDoc=xmlhttp.responseXML;

There is actually a URL in the second parameter, and if I paste the URL directly into a browser, it shows me the XML.   However, it doesn't work when I call it between the script tags.   I get the access denied error.   How do I get around this?
saturationAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
>> I get the access denied error.
That's because the browser does NOT allow you to request data from an "External" domain. In other words, if the page where you have that code is currently at:
http://www.yoursite.com/ajax.html,

Then you can request files that reside ONLY in http://www.yoursite.com. IF you tried to get a file from http://www.yahoo.com, you will get that error.

>>How do I get around this?
You begin by accepting the fact that for security reasons, the browser disallow this.  Your alternative is to create a server side script that will get the "external" file for you.

To clarify, create a file on your server (let's call it fetcher.php). Then in your ajax script you call fetcher.php (because it is in your domain). When fetcher.php, is called, IT will fetch the remote url for you and passes the result to your ajax script:
<?php

echo file_get_contents('http://www.yahoo.com');
?>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
saturationAuthor Commented:
Exactly what I was looking for.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.