Here's a bit of code I've just ripped from something I made.
It uses the prototype JS library and makes a form submit via AJAX rather than by normal methods, though it will fall back on a standard method should the user not have JavaScript enabled:
HTML Code:
<form action="/dynamic_search" method="post" onsubmit="new Ajax.Updater('searchresult', '/dynamic_search', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">
<input id="searchkey" name="searchkey" type="text" />
<input name="commit" type="submit" value="Search" />
</form>
That was built by Rails using Rails code rather than JavaScript, but I'll go over it anyway as it shouldn't be too hard to read...
Code:
<form action="/dynamic_search" method="post"
Standard form element in HTML that will go to "dynamic_search" or wherever you point it if JS is turned off or not supported.
Code:
onsubmit="new Ajax.Updater('searchresult', '/dynamic_search', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"
When the user submits the form via the submit button the JS is triggered.
The Ajax.Updater() is part of Prototype, and it does what it sounds like, it updates the page with AJAX techniques (sending a request and then using the DOM to make changes to the page).
The main things you need to think about here are the first argument, which is the I.D. of the element you're updating (in this case, it's a div for the search results, thus we called it 'searchresult') and the second argument, which is where the script is pointed, which can be the same place as the non-AJAX location, or somewhere else if you want it to look a little better (if you want a full page rather than just the results).
Then you just throw in your input fields and close the form.
Accessing the form data should be as easy as normal.
You could also use observers for this to cut out the submit button completely, though this might be a bit less efficient at times.