Submit a form without query string
<p>I'm on a page like <code>http://example.com?query=value</code> that has a form <code>&lt;form id="formId" method="POST"&gt;</code>. </p>

<p>What's the best way to submit the form to <code>http://example.com</code> without the query string? </p>

<p>I'm currently trying:</p>

<pre><code>$('#formId').submit(function(e){
    e.preventDefault();
    var url = window.location.href; 
    if (url.indexOf("?") != -1){
        $('#formId').attr('action', url.split("?")[0]);
    }
    $('#formId').submit();
});
</code></pre>

<p>but it doesn't seem to be working. </p>

<p>I prefer a javascript/jQuery solution as this pattern is common through the site</p>