Why serialize (Jquery) does not include submit button name?
In PHP I normally do this:
if (isset($_POST['submit_signup'])) {
print_r($_POST);
//Then check firstname, password, etc POSTS
}
That don’t work, what is the solution to this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not sure if this is the most elegant solution, but you can use a hidden input box to contain a value (preferably something that changes, like a sort of hash) and check for that. Like:
And in your code you can do:
Warning: A hash is not a security thing here, only a way to do the same thing you’re used to.
Small Update: I noticed you also asked ‘why’ JQuery does not include the submit button in the
serialize()output. This is default behaviour as specified in the HTML draft(s). As long as no submit button is pressed, it should not be included in the submitted (or serialized) data. The JQuery creators decided to honour that and not include it in the serialized string.