title: Ajax: How to use a variable in the data field
body: <p>I have a ajax function which gets some graph data from a database.
  It works fine but I want to make it generic.</p>
  
  <pre><code>function getGraphData() {
      $.ajax({
          url: "/wordpress/wp-admin/admin-ajax.php",
          method: "POST",
          data: { action: "databaseName" },
          success: function (response) {
              //Some code;
          }
      })
  } 
  </code></pre>
  
  <p>So to make the function generic I need to pass a database name to the function instead of hard code it but I can't seems to get it to work.</p>
  
  <p>I changed the code to this:</p>
  
  <p>Function call:</p>
  
  <pre><code> var dbname = "action: " + "mydatabase";
   getGraphData(dbname); 
  </code></pre>
  
  <p>Changed function:</p>
  
  <pre><code>function getGraphData(database) {
      $.ajax({
          url: "/wordpress/wp-admin/admin-ajax.php",
          method: "POST",
          data: database,
          success: function (response) {
              //Some code;
          }
      })
  }  
  </code></pre>
  
  <p>Where do I go wrong ??</p>
  
  <p>Regards
  Flemming.</p>