AJAX Proxy
Some browsers don't allow JavaScript code to connect to external servers directly.
Therefore, you may need to send requests through the AJAX proxy.
The AJAX proxy is part of the AJAX Toolkit. Access it using remoteFunction defined in connection.js. You can specify any HTTP method in remoteFunction, for example HTTP GET or POST, and it will be forwarded to the external service.
The following examples illustrate typical approaches for GET and POST:
GET Example:
sforce.connection.remoteFunction({
url : "http://www.myExternalServer.com",
onSuccess : function(response) {
alert("result" + response);
}
});
POST Example:
var envelope = ""; //request envelope, empty for this example
sforce.connection.remoteFunction({
url : "http://services.xmethods.net:80/soap",
requestHeaders: {"Content-Type":"text/xml",
"SOAPAction": "\"\""
},
requestData: envelope,
method: "POST",
onSuccess : function(response) {
sforce.debug.log(response);
},
onFailure : function(response) {
alert("Failed" + response)
}
});