JSSCxml <fetch>

The <fetch> element can be used wherever executable content is allowed and has a structure similar to <send>. It provides SCXML running on Web clients with easy access to the familiar HttpRequest facility used in most Web applications, and, unlike <send>, it makes the HTTP response available to the calling SCXML instance by sending callback events.

Namespace

The namespace for <fetch> as well as its <header> children must be "http://www.jsscxml.org", for which I suggest the shorthand "jssc". Thus:

<scxml xmlns="http://www.w3.org/2005/07/scxml" xmlns:jssc="http://www.jsscxml.org">
…
<jssc:fetch target=…
	<jssc:header …/>
	<content expr="…"/>
</jssc:fetch>
…

Attribute detail

NameRequiredTypeDefault valueValid valuesDescription
callbackfalse, and no more than one of those twoEventType.datatypenoneName of the event that will be sent when the HTTP response is available.
callbackexprVale expressionnoneEvaluates when the <fetch> element is executed, used as if there had been a callback attribute with the resulting value.
targettrue, and only one of those twoURInoneAny value accepted by XmlHttpRequest()The request wil be sent there.
targetexprVale expressionnoneEvaluates when the <fetch> element is executed, used as if there had been a target attribute with the resulting value.
enctypefalseFetch.datatypetextone of ["text", "url", "json", "xml"]The request data will be serialized, and its MIME type selected, according to this value.

The <fetch> element also implements the namelist attribute in exactly the same way as <send>.

Children

Behavior

When executed, the <fetch> element causes an XMLHttpRequest to be sent to the specified target.