Now, there are a number of solutions to this problem. Instead of explaining them all to you, lemme provide you the simplest one: using a PHP transport file. If you already know the thing and just need the script, download from here.
Others, let’s see an example implementation first.
9: xmlHttp.open("GET", 'http://myserver.com/transport.php?action=' +
10: urlencode('different-server.com/return_call.php') +
11: '&method=get&data1=101&data2=pass', true );
Now, lets see how it works:
- The script makes an AJAX call to the myserver.com/transport.php with a few parameters:
- action = the target URL you need to fetch, from a different domain
- method = the HTTP method (post/get)
- data1, data2 = sample parameters for using as either query-string or POST fields
- When the request is received by transport.php, it uses cURL to make a call to the page mentioned in action.
- Based on the method, it either makes a GET request or a POST request. In both cases, it sends the extra parameters that are sent.
- After the response is received, transport.php echoes it. So, you have what you need!
Cross-Domain AJAX call transporter.
Downloaded: [downloadcounter(transport)] times