The first one its component ajax to update a partial, i passed this problem too.
The second its in page cms, put this code on " code window".
To make the first one run you need put the right scripts on your layout, after you can paste this code on your conponent.php -->
public function onTest()
{
$this->page['result'] = input('value1') + input('value2');
}
you must have thats scripts on you " assets/vendor" on you theme .
jquery.js and boostrap.js
paste those codes on buttom of your layout
<script src="{{ 'assets/vendor/bootstrap.js'|theme }}"></script>
<script src="{{ 'assets/javascript/app.js'|theme }}"></script>
then you must put the component on you page and update you browse (chrome ex) and voilá
if you do right all those steps, this exemple code will run.