Prerequisites: In order to follow along, you'll need to set up an HTTP server and run the TaxServer container on your local machine. For the purposes of this tutorial, we'll assume that you have a working server running locally, serving content to http://localhost. You'll also need to install Docker locally.
To launch a TaxServer container, at a command prompt:
docker run -it --rm -p 8000:80 calibertechnology/taxquery --cors=http://localhost
This starts up the docker image listening on port 8000 for http requests. The "--cors=" argument tells TaxServer to allow cross-site AJAX requests from localhost, which is considered a different origin since it's on a different port. Note that this requirement is specific to AJAX.
With an HTTP server and the docker image running, we're ready for some preliminary html and javascript code. We won't call the TaxServer backend yet, we'll just get a simple form started, with some helper functions compute, getFloat, and getInt.
index.html: Javascript:
Result:
Here's the results so far. When you click 'Compute', you should get an alert box with the earnings, payperiod, and filingstatus values.