title: What's the best way to send user-inputted text via AJAX to Google App Engine?
body: <p>I'm developing in Google App Engine (python sdk) and I want to use jQuery to send an Ajax request to store an answer to a question.</p>
  
  <p>What is the best way to send this data to the server?  Currently I have:</p>
  
  <pre><code>function storeItem(question_id) {
          var answerInputControl = ".input_answer_"+question_id;
          var answer_text = $(answerInputControl).text();
          $.ajax({
              type: "POST",
              url: "store_answer.html",
              data: "question="+question_id,
              success: function(responseText){
                  alert("Retrieved: " + responseText);
              }
          });
      }
  </code></pre>
  
  <p>This takes a question Id and provides it to the server via the query string.  But on the server-side, I'm unable to access the content of the answer control which I want to store.  Without Ajax, I'm able to perform this operation with the following:</p>
  
  <pre><code>class StoreAnswers(webapp.RequestHandler):
  def post(self):
      question_id = self.request.get("question_id")
      answer_text = self.request.get("input_answer" + question_id)
  </code></pre>
  
  <p>But when doing this call through Ajax, my <code>answer_text</code> is empty.  </p>
  
  <ul>
  <li>Do I need to send the contents of this control as part of the data with the Ajax request?  </li>
  <li>Do I add the control itself to the query string?  Its contents?  Does it matter that the content might be a few hundred characters long?  Is this the most-recommended practice?</li>
  <li>If sending it as a query string, what's the best way to escape the content so that a malicious user doesn't harm the system?  </li>
  </ul>