title: Send variable from JavaScript into Flask
body: <p>I'm a complete beginner here and facing a problem in passing javascript variable into flask. Please note that my question is completely different from previous question that has been asked.</p>
  
  <p>This is my code:</p>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>var dd = {'mvar': 1};
  
      $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "/",
        data: JSON.stringify(dd),
        success: function (data) {
          alert("DONE!")
        },
        dataType: "json"
      });
  </code></pre>
  
  <p><strong>Flask(edited)</strong></p>
  
  <pre><code>@app.route('/', methods=['GET', 'POST'])
  def new():
  
    form = InputForm(request.form)
    v = request.get_json().get('mvar')
    print(v)
  
    return render_template('new.html',form=form,v=v)
  </code></pre>
  
  <p>However, when the output that I get when print out the result is "<strong>None</strong>" while I expected it to be "<strong>1</strong>"</p>
  
  <p>Really hope that experts can help me, thank you!</p>