title: jQuery .serialize() for post?
body: <p>I am doing an ajax request through post that contains a forms variables.</p>
  
  <p>the data for the ajax request looks like</p>
  
  <pre><code>data : {
    somevar1: 'someval1',
    somevar2: 'someval2',
    somevar3: 'someval3',
    somevar4: 'someval4',
    form:     FORMDATA
  }
  </code></pre>
  
  <p>as you can see, as well as the basic form data I am also passing through some other data.</p>
  
  <p>this means that I cannot use jquery <code>.serialize()</code></p>
  
  <p>I am wanting to end up with something that I can send through so on the other side I can just do</p>
  
  <p><code>$_POST['form']['fieldname']</code></p>
  
  <p>is there a built in function do do this?</p>
  
  <p>or what would I need to do to create one?</p>
  
  <p>the possibility of running a function on the form that does something like</p>
  
  <pre><code>function postArray(form){
    var data = {};
    var name, value = null;
    $(form).children('textarea, input, select'){
      name = this.name;
      data.name = $(this).val();
    }
    return data;
  }
  </code></pre>
  
  <p>over the form could work.</p>
  
  <p>and having</p>
  
  <pre><code>data : {
    somevar1: 'someval1',
    somevar2: 'someval2',
    somevar3: 'someval3',
    somevar4: 'someval4',
    form:     postArray(form)
  }
  </code></pre>
  
  <p>would it work?</p>
  
  <p><hr />
  I could use <code>.serializeArray();</code>
  But on the other side I get</p>
  
  <pre><code>Array
  (
    [0] =&gt; Array
      (
        [name] =&gt; name1
        [value] =&gt; val1
      ),
    [1] =&gt; Array
      (
        [name] =&gt; name2
        [value] =&gt; val2
      )
    ...
    [8] =&gt; Array
      (
        [name] =&gt; name8
        [value] =&gt; val8
      )
  )
  </code></pre>
  
  <p>Which is close, but that requires me to either<br>
  a: loop over the array and convert it to what I want<br>
  b: every time i use it loop over it to find the right key</p>