Get the original url in this case with jquery
<p>In the form below, I change the action attribute and submit the form. That works fine. What goes on is: if the current location is <code>http://localhost/search/?mod=all</code> and the search term is 14, the action will be changed to <code>http://localhost/search/?mod=all&amp;handle=14</code> and so will the url in the browser. </p>

<p>But the next time I try to search, since the url now is <code>http://localhost/search/?mod=all&amp;handle=14</code>, I get <code>http://localhost/search/?mod=all&amp;handle=14&amp;handle=15</code>. It'll keep going on and on with each search term. </p>

<p>Any idea how I can retain the orginal url <code>http://localhost/search/?mod=all</code> through this all.  </p>

<p>Here's the form:</p>

<pre><code>&lt;form method="GET" class="modForm" action=""&gt;
&lt;input type="text" placeholder="Search" class="modSearchValue"&gt;
&lt;input type="radio" name="text" value="text" class="text" title="Search"&gt;
&lt;/form&gt;
</code></pre>

<p>Here's the jquery:</p>

<pre><code>$('.modForm').submit(function(event) {

        var $this = $(this);

        var query = $this.find('.modSearchValue').val(); // Use val() instead of attr('value').
        var locale = window.location;
         if($('.text').is(':checked')){query = '&amp;text='+query;}else{query = '&amp;handle='+query;}
        route = locale+query;
        console.log(route);

        if (query.length &gt;= 1) {
        // Use URI encoding
        var newAction = (route);
        console.log(newAction); // DEBUG
        // Change action attribute
        $this.attr('action', newAction);
        //event.preventDefault();
        } else {
        console.log('Invalid search terms'); // DEBUG
        // Do not submit the form
        event.preventDefault();
        }
    });
</code></pre>
