APIs, SDKs, and Services > Embedding Request Forms in Standalone Web Pages > Making Cross Domain AJAX Requests
  

Making Cross Domain AJAX Requests

Cross Domain Proxy
One approach to making cross domain AJAX request is to use a proxy. In this scenario, your script calls an endpoint on your Web application server that is hosting your script and application. That endpoint in turn forwards (proxies) all requests to the actual destination (for example, the Process Server engine where your services are hosted).
JSON with Padding (JSONP)
When making JSONP request, the string version of the JSON data must be sent in a parameter named _json and the callback function name using parameter named callback (if a value is not given, the engine does a callback to jsonpCallback()). Since JSONP requests are based on the HTTP GET method, the amount of data that can be sent in a HTTP query string is limited. This means, JSONP requests are better suited for request messages whose payload is small. Note that attachments are not supported with JSONP.
The basic format of a JSONP request to service deployed on ProcessaServereis:
http://host:port/active-bpel/services/JSON/serviceName?callback=s
callbackFnName&_json=string_version_of_json
You can use the helper function AE_AJAX_SERVICE_UTIL.getJSON(...) for JSONP.

var getTasksRequest = {
"getMyTasks" :
{
"xmlns" : "http://www.example.org/WS-HT/api/xsd",
"taskType" : { "$t" : "TASKS" },
"genericHumanRole" : { "$t" : "POTENTIAL_OWNERS" },
"status" : [ {"$t" : "READY"} , {"$t" : "RESERVED"} ],
"maxTasks" : { "$t" : "5"}
}
};

// get task list using JSONP
AE_AJAX_SERVICE_UTIL.getJSON(
// task-client service url
"http://localhost:8080/active-bpel/services/JSON/AeB4PTaskClient-taskOperations",
// req.
getMyTasksRequest,
// success callback of JSON data
function(aJsonResponse) {
alert("Success!");
// handle result. e.g. display results in a table
},
// fault callback of JSON data
function(aJsonFault) {
alert("Fault!");
},
// http error callback
function(aStatusCode, aStatusMessage) {
alert("Transport error: " + aStatusCode + " " + aStatusMessage);
}
);