Example:
$options['onLoading'] = "doit";
$options['onComplete'] = "more";
echo TJavaScript::encode($options);
expects the following javascript code
{'onLoading':'doit','onComplete':'more'}
For higher complexity data structures use {@link jsonEncode} and {@link jsonDecode}
to serialize and unserialize.