Making an AJAX call acorss domains

RobertEaton used Ask the Experts™
Hey All,
I have two servers sitting on different domains.

Server 1: Hosts php proxy file and a js file
Server 2: Hosts basic html page calling the above two (can't host proxy on this server as it requires the SOAP client, and I can't change my php build)

It seems this can't happen in most secure browsers, but from what I've read, you can do this using AJAX. Unfortuantely, there is no way to get everything on the same domain. Could someone confirm whether this is possible or not? My apologies for the distinct 'newbiness' of this question. Thanks everyone!
<input type="hidden" id="AJAXURL" value="http://64..proxy.php.>
<script language="javascript" charset ="iso-8859-1" src=""></script>

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
The JavaScript CAN be loaded from a different URL, but the AJAX call can only be made to the page's OWN domain.

So, your solution is to have the server 2 hosts a PHP page that will call the proxy page on the server 1. Basically the server 2 will have to rely AJAX requests to server 1 and return the result to the client.

Security-wise, you have to check that you are relaying to a know server (i.e. server 1) otherwise your server 2 could be used to launch cross-site attacks by hackers.
Expert of the Year 2008
Top Expert 2008
for security reasons the browser does not allow you to make cross domain ajax calls. However, this restriction applies to the client(browser). Server's typically don't have such restriction. So, what you need to do is INSTEAD of sending the request directly to:

You need to set up a page on YOUR server that accepts the url you are interested in. Thus, you will make the request to YOUR server.

Then your server (proxy.php) will fetch that page for you and return the result to the browser. Thus, from the browser's point of view, the content actually resides on YOUR server, not the remote server.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial