Since you've tagged jQuery, I'll use a jQuery example
$(document).ready(function(){ $('form').submit(function(){ $('#content').load('code.php'); return false; })})
This makes a couple of assumptions here
- This assumes that code.php is in the same path that you are in now.
- There is only one form in the page.
- As @johnhunter points out, this example obviously won't work with post. You can send the post data along with the method. See here for usage : http://api.jquery.com/load
EDIT
Here's a fiddle example : http://jsfiddle.net/jomanlk/J4Txg/
It replaces the form area with the content from jsfiddle/net/echo/html (which is an empty string).
NOTE 2 Make sure to include the code in $(document).ready()
or include it at the bottom of the page. It goes without saying you need jQuery in your page to run this.