views:

381

answers:

1

I have a form loading inside my page and there is a button out side this form its function is to submit this form.

$('#MyForm').submit();

I want a way to write a submit complete function, means to know that the form successfully/completely submitted.

I tried the jquery form plugin, but didn't work, i think because the submit come from a button outside the form.

anyone knows any different ways?

+1  A: 

Actually, you can use the jquery form plugin, just use the ajaxSubmit() method.

Documentation for the jQuery form plugin.

// setup the form, and handle the success
$('#myFormId').ajaxForm({
  success: function() {
     // do what you are looking to do on 
     // success HERE
  }
});

// setup submission on some random button
$('#someButton').click(function() { 
    // submit the form from a button
    $('#myFormId').ajaxSubmit(); 
});
altCognito