You can use a generic classname on all your forms.

<form action="process1.php" id="form1" class="myForm">
...
</form>

<form action="process2.php" id="form2" class="myForm">
...
</form>

$(function() {
     $(".myForm").submit(function(){
          $.post($(this).attr("action"),
               $(this).serialize(),
               function(response,mystatus) {
                    alert('response: ' + response + " status: " +
status);
               });
               return false;
          }
     });
});


On Feb 11, 6:18 am, Tim Johnson <t...@johnsons-web.com> wrote:
> On Tuesday 10 February 2009, mkmanning wrote:> For the second argument use 
> $(form).serialize()
>
> > You should also use onsubmit="return CheckForm0(this);"
> > although the best practice would be to remove the inline script and
> > bind
> > the submit event like this:
> >  $('form').submit(function(){
> >  //do your ajax here and return false
> > });
>
>   But what would bind the form in your example? I frequently
>   work with multiple forms. I.E. is 'form' in your $.submit()
>   above the name or ID of the form or is it an object from which
>   name or ID could be extracted as a property.
>   Thanks
>   Tim

Reply via email to