1

how can i get the parameters of any form being submitted with method=post before it's submitted using javascript(preferably jQuery). What i am trying to do is get the post parameters and submit it to an alternate loacation. i was using

$('form').submit(function() {
  alert('action=  ' + $(this).attr("action"));
  alert('serialized string' + $(this).serialize());
  return false;
});

but it works only with get request i want to extract the parameters from the post requests too .

1
  • 1
    Serialization should have nothing to do with what type of method the form uses to make the request. I use serialize with forms that POST all the time. Perhaps you have something else that's going wrong? Commented Mar 31, 2010 at 12:23

1 Answer 1

1

Something like this works for me

$('#form').submit(function(){
        $.post(your_location, $(this).serialize());
    return false;
  });

You can use the any other Ajax method you like if you don't want to use $.post(). You can also include a callback method to handle whatever your ajax call returns.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.