Passing form values on a submit to an ajax call
<p>I have a common case of allowing a user to submit a form with some values and needed to pass those values to my ajax call. This approach works, but is there a more elegant/efficient way of accessing the form values other than using selectors?</p>

<pre><code>$("#myForm").submit(function(){

myData = {name: $("#name").val(), age: $("#age").val()}

  $.ajax({
    url: "foo.php",
    data: myData, 
    type: get
  });
});

&lt;form id="myForm"&gt;
Name: &lt;input type="text"  id="name"&gt;
Age: &lt;input type="text" id="age"&gt;
&lt;/form&gt;
</code></pre>
