For a function call you’d need a POST request, rather than the GET request your browser is making. If you want to just test for functionality, you could try this page to test the functions easily: http://jordymoors.nl/interface
If you want to learn how to do it yourself, go with this:
Tutorial: Spark Variable and Function on One Web Page
Or using the JS library perhaps this one: