Setting default values by URL

The widget will accept a url to load default values. This would be very useful in a portal environment where the user is known and his/her calculator values are defined. The calculator will load the model from the url via AJAX. We use JSONP with a callback method.

Example - model from url

Indiana work location, gross pay of $77,000 and one custom deduction

<script async src="https://calculators.symmetry.com/widget/js/salary.js?key=yourKey" 
    data-defaults='{"url":"https://calculators.symmetry.com/docs/examples/model.json"}'></script>

Following file hosted at https://calculators.symmetry.com/docs/examples/model.json

jsonCallback(
  {
    "model": {
    "grossPay":"77777",
    "grossPayType":"ANNUALLY",
    "grossPayYTD":"10000",
    "payFrequency":"SEMI_MONTHLY",
    "federalFilingStatusType":"MARRIED",
    "federalAllowances":"4",
    "additionalFederalWithholding":"100",
    "roundFederalWithholding":true,
    "exemptFederal":false,
    "exemptFica":false,
    "exemptMedicare":false,
    "state":"IN",
    "voluntaryDeductions[0][deductionAmount]":"5"
    }
  }
);

📘

Important note:

The widget will still load if an invalid url or bad JSON is passed to it.


Jump to top