Passing form values on a submit to an ajax call
===

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?

    $("#myForm").submit(function(){

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

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

    <form id="myForm">
    Name: <input type="text"  id="name">
    Age: <input type="text" id="age">
    </form>