Added global window for jshint
Added space between function and ( for declarations
moved repeated calls to encodeURIComponent outside loop
Removed async option, and made all requests asynchronous
Moved var declarations to top of closure
Corrected var declarations