How do I set post variables dynamically?
<p>I am making a post call and want to set the paramaters I send dynamically through some if/else statements. The following simplified version doesn't work but if I change '{postvars}' to '{n: n}' then it does, even though they're equivalent, right? </p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;/title&gt;
&lt;script type="text/javascript" src="jquery-1.7.1.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
   $(document).ready(function () {

   $("#clicky").click(function () {
     var postvars; var mydata;
     var n = 'dave';
     postvars = 'n: ' + n;

      $.post("test.php", 
     {postvars}, 
      function(data){
          }, 
        "text"
        );  

$("#test").text(postvars);

  });
   });
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;div id='clicky'&gt;click here&lt;/div&gt;
&lt;div id='test'&gt;&lt;/div&gt;

&lt;/body&gt;


&lt;/html&gt;
</code></pre>
