JavaScript isn't allowed to make cross-domain requests. It's a big security risk. Instead, you'll have to execute a script on the server and have it return the results to your JavaScript function.
For example, assuming that you're using JavaScript and PHP you could setup the application to work like this:
JavaScript initiates an Ajax request to a page (or script) located on your server. It passes any required parameters to this page. The following code is based on jQuery (for the sake of being concise), but the principles are the same regardless of your framework.
var sParameters = " ... " // this is defined by you
$.ajax({
url: 'your-server-side-code.php',
processData: false,
data: sParameters,
success: function(sResponse) {
// handle the response data however you want
}
});
The server-side code will respond to the request and pass along the necessary parameters to the cross-domain website. PHP's cURL library is good for this.
// very contrivuted cURL configuration for purposes of example...
$curl_connection = curl_init();
$str_url = "http://you-url.com";
curl_setopt($curl_connection, CURLOPT_URL, $str_url);
curl_setopt($curl_connection, CURLOPT_GET, 1);
// ... keep setting your options ...
$str_response = curl_exec($curl_connection);
curl_close($curl_connection);
When the cross-domain website responds, your server-side code can echo the response back to the initial request. This should probably be validated before responding back, but it's just an example.
print_r($str_response);
A JavaScript response handler function can then parse the incoming response data. Note the success function in the first block of JavaScript code above.