window.location was giving odd behavior with result download. changed to a.href and it's working perfectly.