title: jQuery incorrect handling of array when URL-encoding object?
body: <p>When passing an object as the <code>data</code> to the <code>ajax</code> call, I am getting some unexpected results. For some reason, jQuery is adding square brackets to my parameter names if their value is an array. For instance...</p>
  
  <pre><code>var obj =
      {
          name: "John Doe",
          courses: [ 1, 2, 4 ]
      };
  </code></pre>
  
  <p>...becomes <code>name=John+Doe&amp;courses[]=1&amp;courses[]=2&amp;courses[]=4</code> instead of <code>name=John+Doe&amp;courses=1&amp;courses=2&amp;courses=4</code>.</p>
  
  <p>Why is jQuery adding the square brackets?</p>
  
  <p>Here is a working example: <a href="http://jsfiddle.net/BrHSy/" rel="nofollow">http://jsfiddle.net/BrHSy/</a></p>
  
  <p><strong>Update:</strong></p>
  
  <p>I expect the above example to produce a string similar to the query string in this example:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;&lt;/head&gt;
      &lt;body&gt;
          &lt;form method="GET"&gt;
              &lt;input type="hidden" name="name" value="John Doe"/&gt;
              &lt;input type="hidden" name="courses" value="1"/&gt;
              &lt;input type="hidden" name="courses" value="2"/&gt;
              &lt;input type="hidden" name="courses" value="4"/&gt;
  
              &lt;button&gt;Go!&lt;/button&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Notice that the query string which is produced by the form (www-form-urlencoded) does not have the square brackets.</p>