Using jquery to make a POST, how to properly supply 'data' parameter?
<p>I'd like to make an ajax call as a POST, it's going to go to my servlet. I want to send parameterized data, like the following:</p>

<pre><code>var mydata = 'param0=some_text&amp;param1=some_more_text';
</code></pre>

<p>I supply this as the 'data' parameter of my jquery ajax() call. So this should be inserted in the body of the POST, right? (I mean, not appended to my 'mysite/save' url?):</p>

<pre><code>$.ajax({
    url: 'mysite/save',
    type: 'POST',
    data: mydata
});
</code></pre>

<p>it appears to work correctly. In my servlet, I am just dumping all received parameters, and I see them all come through nicely:</p>

<pre><code>private void printParams(HttpServletRequest req) {
    Enumeration paramNames = req.getParameterNames();
    while (paramNames.hasMoreElements()) { 
        // print each param key/val here.
    }
}
</code></pre>

<p>also, I should url encode my data string manually before use, right? Like:</p>

<pre><code>var mydata = 'param0=' + urlencode('hi there!');
mydata += '&amp;param1=' + urlencode('blah blah');
mydata += '%param2=' + urlencode('we get it');
</code></pre>

<p>Thanks!</p>
