AJAX is the standard for Asynchronous Javascript and allows dynamic variables to be loaded into a page. In WattmonOS, the home page uses AJAX to update its parameters once per second.
Various packages may insert hooks that generate content in the AJAX output. All parameters in the AJAX page are JSON-encoded.
In order to send parameters to the home page, your script should output one or more lines of valid JSON data, with a key and value in the format:
"numeric_key":1, "string_key":"my string", "array_key":[1,5,6], "object_key":{"name":"Joe","age":21}, "array_object_key":[ {"name":"Joe","age":21}, {"name":"Jane","age":32} ],
End each parameter with a comma (,).
Below is an example script that will increment a global variable 'cnt' and send it to the AJAX output.
Example output of this:
"cnt":334,
Note that the hook 'In Ajax Generation' needs to be selected for this.
To see how to use this variable on the home page, see Blockly Home Page Hook