AJAX Molecule

Enable droplet to perform ajax communications.

Summary
AJAX Molecule
Preference Dialog
CommentsAjax does not allow cross domain requests unless Cross Origin Sharing (CORS) is enabled on the target server.
Properties
typestring, ( r )
pref.namestring, ( r )
pref.urlstring, ( r, w )
pref.typestring, ( r, w )
pref.withDatastring or object, ( r, w )
pref.isTriggerEventbool, ( r, w )
pref.eventNamestring, ( r, w )
pref.isBroadcastbool, ( r, w )
pref.targetsarray, ( r, w )
pref.scriptNamestring, ( r, w )
pref.userstring, ( r, w )
pref.passwordstring, ( r, w )
pref.withCredentialsbool, ( w )
responseHeadersstring, ( r )
requestHeadersobject, ( w )
mimeTypestring, ( w )
crossOriginbool, ( w )
Functions
attach
detach
delete
rename
clone
serialize
apply
getResponseHeader
exec

Preference Dialog

Comments

Ajax does not allow cross domain requests unless Cross Origin Sharing (CORS) is enabled on the target server.  If the target server is CORS ready, you need to set crossOrigin to true before starting the request.

IMPORTANT However, if the target server is not CORS ready, this Ajax molecule preforms server tunneling to fetch the content for you.  This is automatically triggered by cross domain requests.

Properties

type

string, ( r )

Type of this molecule, ajax.

pref.name

string, ( r )

The scriptable name for this molecule.  This name can be set using rename function dynamically.

pref.url

string, ( r, w )

The target URL.

pref.type

string, ( r, w )

The type of ajax operation.  ‘GET’ or ‘POST’.

pref.withData

string or object, ( r, w )

Specifies an object or the name of an Object molecule that is to be used as the post data in the AJAX POST operation.  The object’s properties, key/value pairs, are automatically concatenated.

pref.isTriggerEvent

bool, ( r, w )

Specifies whether to send an event or execute a script when AJAX completes.

pref.eventName

string, ( r, w )

Specifies the custom event name that this molecule sends out when AJAX completes.

pref.isBroadcast

bool, ( r, w )

Specifies whether the event is sent to all droplets or a few selected droplets in a group.

pref.targets

array, ( r, w )

Specifies the list of droplet names that the event is sent to when AJAX completes.

pref.scriptName

string, ( r, w )

Specifies javascript function name that will be executed when AJAX completes.

pref.user

string, ( r, w )

Specifies user name if this ajax requires http authentication.

pref.password

string, ( r, w )

Specifies password if this ajax requires http authentication.

pref.withCredentials

bool, ( w )

Indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies or authorization headers.  The default is false.

responseHeaders

string, ( r )

Obtains the response header after ajax session is complete.

requestHeaders

object, ( w )

Sets the request headers before commencing ajax session.  The input should be an object of key/value pairs.  (e.g.  {‘Content-Encoding’: ‘gzip’, ‘Content-Length’: 2500}.)

mimeType

string, ( w )

Specifies the desired mimeType of server response.

crossOrigin

bool, ( w )

Specifies whether the target server allows crossOrigin ajax.

Functions

attach

attach(droplet);

Attach this molecule to the given droplet.

Parameters

droplet(object) a droplet.

Returns

N/A

detach

detach();

Remove this molecule from its droplet.

Parameters

N/A

Returns

N/A

delete

delete();

Delete this molecule.

Parameters

N/A

Returns

N/A

rename

rename(name);

Rename this molecule.

Parameters

name(string) a new name.

Returns

N/A

clone

clone();

Create a clone of this molecule.

Parameters

N/A

Returns

(object) a molecule.

serialize

serialize();

Serialize this molecule into its JSON representation.

Parameters

N/A

Returns

(string) JSON representation of a molecule.

apply

apply(params);

Execute the script associated with this alias.

Parameters

params(object) input parameters.

Returns

N/A

getResponseHeader

getResponseHeader(label);

Returns the response header of given header label.

Parameters

label(string) a header label.  (e.g.  ‘Content-Length’.)

Returns

(string) a header value.

exec

exec(url, data);

Executes the ajax request.

Parameters

url(string) the target URL.
data(object) Optional.  An object of the form {key1: ‘value1’, key2: ‘value2’} and it is converted to key1=value1&key2=value2 before it is sent to the server in a post reqest.

Returns

N/A

bool, ( w )
Close