Dialog form load/submit

Dialog form load/submit

Hi, there!

I'm trying to show a form loading the template in a dialog like:

  1. $('#form_dialog').load(url).dialog({
  2. bgiframe: true,
  3. autoOpen: false,
  4. height: 330,
  5. width: 800,
  6. modal: true,
  7. buttons: {
  8. "Cancel": function() { 
  9.  $(this).dialog("close"); 
  10. }
  11. }
  12. });
The problem I've found it's when I try to submit the form, it redirects me to the page I've loaded in the dialog.
Is that a wrong way to show and submit forms? 

How I have load the form and submit it through the dialog? only with an javascript form and sending an ajax request?

Thanks!