I am creating this Visual force page that will heavily rely on the Ajax tool kit and trying to do it asynchronous style, because I think that is what the cool kids are doing.
Is it not possible to return a value from the "success" function to a global variable "result" ? right now it is return undefined.
Here is a snippet of what I am trying to do:
var result = sforce.connection.query("SELECT TargetObjectId FROM ProcessInstance Where Id IN (SELECT ProcessInstanceId FROM ProcessInstanceWorkitem)", {
onSuccess : success,
onFailure : failure
});
function success(result) {
var records = result.getArray("records");
var result2 = new Array();
var recLength = records.length
for (var i=0; i<recLength; i++) {
result2.push(records[i].TargetObjectId);
}
return result2;
}
document.write(result);
Any thoughts, should I just do it the synchronous way?