DEMOS / Javascript API

The #api{} element allows you to create a Javascript API function on your page that will fire requests back to Nitrogen. API postbacks are handled by api_event(Name, Tag, Arguments).

The name property specifies the name under which the function will be exposed.

The tag property allows you to include an opaque value that is passed into the event. It is not exposed to the client.

The arguments are an Erlang term that maps to the arguments you specified in Javascript. These are true Erlang arguments, and can be used for pattern matching. Nitrogen uses BERT-JS to encode Javascript terms into an Erlang binary.

This demo sets up three Javascript APIs on the page, called via the links on the right.

View Module Source
Copyright © 2008-2024 Nitrogen Web Framework. Released under the MIT License.