title: preventDefault() won't stop the page from refreshing
body: <p>So, a bit of background for starters.</p>
  
  <p>I'm following the link below to do a simple post request.</p>
  
  <p><a href="https://codehandbook.org/python-flask-jquery-ajax-post/" rel="nofollow noreferrer">https://codehandbook.org/python-flask-jquery-ajax-post/</a></p>
  
  <p>I have done everything as it says and the page -surprisingly- works. The only problem is that it still keeps refreshing the page whenever I press "submit" even with the <code>preventDefault()</code> function in it.
  It is supposed to do some stuff in Flask with the variables I give it in the HTML below and before I get to that I would like to get rid of this little annoyance.</p>
  
  <p>Here's my HTML:</p>
  
  <pre><code>&lt;fieldset&gt;
  &lt;form&gt;
      Yrityksen nimi: &lt;input name="Yrityksennimi" type="text" id="YN"  placeHolder="yritys" &gt;&lt;/input&gt;&lt;br&gt;
      Ennustettu kasvu: &lt;input name="Ennustettukasvu" type="number" min="1" max="2" step="0.001" value="1" id="kasvu"&gt;&lt;br&gt;
      Diskonttokorko: &lt;input name="Diskonttokorko" type="number" min="0" max="1" step="0.001" value="0" id="DK"&gt;&lt;br&gt;
      BKT: &lt;input name="BKT" type="number" min="0" max="1" step="0.001" value="0" id="BK"&gt;&lt;br&gt;
      Osakkeiden yhteenlaskettu määrä: &lt;input name="Osakkeidenyhteenlaskettumaara" type="number" min="0" max="1000000000000000000000000" step="1" value="0" id="OM"&gt;&lt;br&gt;
      Vapaa kassavirta: &lt;input name="Vapaakassavirta" type="number" min="0" max="1000000000000000000000000" step="0.1" value="0" id="KV"&gt;&lt;br&gt;
      Mittausajan pituus: &lt;input name="Mittausajanpituus" type="number" min="0" max="100" step="1" value="0" id="MP"&gt;&lt;br&gt;
      &lt;input type="submit" name="submit" id="submit"&gt;&lt;/input&gt;
  &lt;/form&gt;
  &lt;/fieldset&gt;
  </code></pre>
  
  <p>Here's the Flask:</p>
  
  <pre><code>@app.route('/DCF-calculator', methods =['POST'])
  
  def DCFcalc():
  
      n = request.form['Yrityksennimi'];
      g = request.form['Ennustettukasvu'];
      dr = request.form['Diskonttokorko'];
      gdp = request.form['BKT'];
      s = request.form['Osakkeidenyhteenlaskettumaara'];
      f = request.form['Vapaakassavirta'];
      v = request.form['Mittausajanpituus'];
  return json.dumps({'status': 'OK', 'YN':n, 'kasvu':g, 'DK':dr, 'BK':gdp,'OM':s,'KV':f,'MP':c});
  </code></pre>
  
  <p>And finally the JavaScript:</p>
  
  <pre><code>$(document).ready(function() {
      $('submit').click(function(e) {
          e.preventDefault();
          var YN = $('#YN').val();
          var kasvu = $('#kasvu').val();
          var DK = $('#DK').val();
          var BK = $('#BKT').val();
          var OM = $('#OM').val();
          var KV = $('#KV').val();
          var MP = $('#MP').val();
          $.ajax({
              url: '/DCF-calculator',
              data: $('form').serialize(),
              type: 'POST',
              success: function(response) {
                  console.log(response);
              },
              error: function(error) {
                  console.log(error);
              }
          });
      });
  });
  </code></pre>
  
  <p>What am I doing wrong?</p>