Newer Version Available

This content describes an older version of this product. View Latest

API Call Syntax in the AJAX Toolkit

SOAP API calls use slightly different syntax in AJAX Toolkit.

Synchronous syntax:

1sforce.connection.method("arg1","arg2", ...);

For example:

1sforce.connection.login("MyName@MyOrg.com","myPassword1");

Asynchronous syntax:

1method("arg1","arg2", ..., callback_method);

For example:

1var callback = {onSuccess: handleSuccess, onFailure: handleFailure};
2function handleSuccess(result) {}
3function handleFailure(error) {}
4sforce.connection.query("Select name from Account", callback);

In this example, onSuccess is the callback function, which will return the results when they are ready.

See Core Calls in the SOAP API Developer's Guide for call usage, arguments, and best practices, but use the AJAX Toolkit syntax for methods you embed in JavaScript.

Because delete is a JavaScript keyword, use deleteIds instead of the API call delete.

Note