Setting window.location is different from calling form.submit(). The former will always do a GET, while the latter -which is what the code you posted is doing- will use whatever the form's action attribute is set to.
The only way to keep parameters out of the URL is to use POST. So if that's the paramount requirement, then you'll need to adapt the code that's forcing you to do a GET.
subject: How to hide the parameters shown in the url while submitting a form