title: Get data from POST ajax call using web2py
body: <p>I'm making an AJAX call to a python function. That function does a database query based on the information sent to the function.</p>
  
  <p>I can't work out how to get the variable that is sent to the function.</p>
  
  <p>I was using request.vars.variableName, and I know the function is valid, it's just not receiving the variable to use properly. How do I get POST sent variables from a python function, using web2py?</p>
  
  <p>ETA: This is the code I was using</p>
  
  <pre><code>jQuery.ajax(
          {type: "POST",
          url: '../../Printed/printedballoons/cost.json', //python function
          data: typeSelected,//data sent to server
          dataType: 'json',
          error: function(msg){$("#ajaxerror").html(msg);},
          success: function(data){
              balloonPrice = data.cost;
          },
          timeout: 2000}
      );
  </code></pre>
  
  <p>The error was in the "data: typeSelected" line, the variable name wasnt associated with any data, so the python query:</p>
  
  <pre><code>cost=db(db.balloonprices.type==request.vars.typeSelected).select(db.balloonprices.cost)
  </code></pre>
  
  <p>was looking for "" as opposed to a anything that actually is in the database.</p>