Pass parameter to Ajax call to use after response returns

Let’s say I have some data I want to pass along with an ajax call to use when the response comes in. You can pass round trip parameters in your jQuery ajax call by adding them to the options object like this

$.ajax({
 url: 'www.example.com/some-api/',
 dataType: "json",
 roundTripVariable: 'Weeeeee!',
 success: function(data, textStatus, jqXHR) {
 // will print 'Weeeeee!' to the console
 console.log( this.roundTripVariable );
 }
});

Validating Bank Routing Numbers In JavaScript

TLDR;
Example code at http://sandbox.michaelgrace.org/bank-routing-number-validation/

I have a test script at http://sandbox.michaelgrace.org/bank-routing-number-validation/ that I recently updated. I am having a hard time finding good documentation on it but ABA routing numbers that start with the number 5 are not valid. Routing numbers that start with 5 are internal bank routing numbers and are not valid for ACH transfers. Customers will often not realize that the routing number on their checks and the routing numbers on their bank deposit slips are different.

Here are the checks that I am doing in my JavaScript example:

  • routing number is a number
  • is 9 numbers in length
  • does not start with the number 5
  • checksum of routing number validates

For more information on the checksum for ABA routing numbers, check out wikipedia.

References for routing numbers starting with 5 being internal routing numbers:

https://firstib.custhelp.com/app/answers/detail/a_id/596
http://productforums.google.com/forum/#!topic/checkout-merchant/9XeAX4LAlqY
http://www.colorado.gov/pacific/osc/direct-deposits

Test Your JavaScript As You Code

If you are writing JavaScript, you should be testing and linting your code often to catch common mistakes. I enjoy using Sublime Text so I have installed Sublime-JSHint, a Submlime Text 2 plugin that checks my JavaScript code for nasty errors and other coding goodies.

Sublime JSHint in action

It’s super easy to setup so what are you waiting for?!

If you don’t use Sublime Text, find a jshint plugin for your editor over at http://www.jshint.com/install/