title: how can I use data posted from ajax in flask?
body: <p>I'm having trouble getting data POSTed from jquery ajax.</p>
  
  <pre><code>$('#clickme').click( function() {
      var data = save_input(); // data
  
      data['_sid'] = $survey_id;  // survey_id injected from flask
      data['_uip'] = $user_ip; // user_ip injected from flask, request.remote_addr
  
      $.ajax({
          type : "POST",
          url : "{{ url_for('mod.load_ajax') }}",
          data: JSON.stringify(data),
          contentType: 'application/json;charset=UTF-8',
          success: function(result) {
              console.log(result);
          }
      });
  
      console.log(data);
  });
  </code></pre>
  
  <p>from the code, <code>data</code> is a javascript object like</p>
  
  <pre><code>{
      'foo' : 'foo',
      'bar' : 'bar',
      'fo_' : 42,
  }
  </code></pre>
  
  <p>what I'm trying to do in flask is :</p>
  
  <pre><code>@mod.route('/load_ajax', methods=["GET", "POST"])
  def load_ajax():
      if request.method == "POST":
          # load _sid and _uip from posted JSON and save other data
          # but request.form is empty.
          # &gt;&gt;&gt; request.form
          # ImmutableMultiDict([]) 
          return str(request.form)
  </code></pre>
  
  <p>see, the ajax request is made but no data is submitted. I do <code>console.log(data)</code> with ajax so I can see that I really have some meaningful data in <code>data</code> variable in jquery. but request.form in ajax view is empty. Where is my data submitted? </p>