title: Getting JSON data in Flask function
body: <p>I am just learning Flask. I am trying to get a JSON object through a jQuery call into flask. My html look like this,</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Passenger&lt;/title&gt;
      &lt;style type="text/css"&gt;&lt;/style&gt;
      &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div&gt;
        &lt;form onsubmit="return false"&gt;
          &lt;input class="name" type="text" placeholder="Name"&gt;
          &lt;input class="submit" type="submit" placeholder="Go"&gt;
        &lt;/form&gt;
      &lt;/div&gt;
      &lt;script&gt;
      $("input.submit").click(function(e){
          $.post( "/save", {name: $("input.name").val(), time: "2pm"});
      });
      &lt;/script&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The Flask app file looks like,</p>
  
  <pre><code>from flask import Flask
  from flask import redirect, url_for, jsonify
  from flask import request
  import json
  app = Flask(__name__)
  
  @app.route('/')
  def home():
    return redirect(url_for('static',filename='index.html'))
  
  @app.route('/save', methods=['PUT','POST'])
  def get_name():
    print request.json
    return request.json
  
  if __name__=='__main__':
    app.run(debug=True)
  </code></pre>
  
  <p>Running this code returns None. I am expecting to get back the JSON object [{name: $("input.name").val(), time: "2pm"}]. Thanks.</p>