title: Button onclick Javascript function fails, but function works
body: <p>In my html document I have this:</p>
  
  <pre><code>&lt;button onclick="doFunction()" type="submit" ...&gt;Button&lt;/button&gt;
  </code></pre>
  
  <p>The function looks like this:</p>
  
  <pre><code>doFunction() {
      var goToThisUrl = "www.spring_controller_method.com?redirectUrl=this_page";
      window.location.href = goToThisUrl;
  }
  </code></pre>
  
  <p>The the url in the doFunction() is the url of a Java Spring controller method. In that method it manipulates the database and returns a string to redirect to the page it came from: return "redirect:" + redirectUrl. </p>
  
  <p>The problem is that the button doesn't work. When I click the button, the page refreshes but the data in the database isn't manipulated. The reason I know this isn't a problem with the spring controller method is because of two reasons:</p>
  
  <ul>
  <li>I have a breakpoint in the controller method and it isn't being hit.</li>
  <li>When I take the same <code>doFunction()</code> code and run it on the Chrome developer console, the controller method breakpoint is hit, and the data in the database is changed.</li>
  </ul>
  
  <p>Is there any idea as to why this would be happening? </p>