Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9113783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:02:41+00:00 2026-06-17T04:02:41+00:00

<form id=formReg action=reg.php method=post> . . . <button id=sub>Register</button> </form> This works, but I

  • 0
<form id="formReg" action="reg.php" method="post">
. . . 
<button id="sub">Register</button>
</form>

This works, but I want to place button #sub outside the form tag, and run the form processing using jquery:

$("#sub").click( function() {
    $.post( $("#formReg").attr("action")),
    $("#formReg :input").serializeArray();      
});

It doesn’t work. Is it possible at all ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:02:42+00:00Added an answer on June 17, 2026 at 4:02 am

    Well, it probably doesn’t work because the form submission cancels the calling of any further event listeners. You should do form processing like this:

    $("#formReg").on('submit', function() {
        // process form
        // You can even stop the form submission here,
        // just return 'false' and it will stop.
        // That's very useful for form validation etc.
    });
    

    If you need that button to submit the form, you could do this:

    $("#sub").on('click', function() {
        $("#sub").submit(); // This will submit the form AND call the event listener. Nice, eh?
    });
    

    That should work whereever the button is on the page.

    EDIT:
    Thanks, fibreFoX, for remembering me of the deprecation of .click() and .submit()!

    EDIT 2:
    Musa is right, you used $.post() incorrectly. But I don’t know if the AJAX request actually completes if the user gets thrown of the page by the form submission. If you don’t want the user to go to the page the form is submitted to, you should return false from the submit listener.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to validate joinUs form <form id=frmReg method=post onsubmit=return valRegs() action=memb_area/register.php> //js: function
form html: <form action='/register/' method = 'post'>{% csrf_token %} ... <label>Avatar: </label><input type='file' name='avatar'
the Form <article id=signup-form> <form id=signupform method=post action=signup.php accept-charset=utf-8> <label for=email>Email Address</label> <input type=text
<script type=text/javascript src=js/js01.js></script> <!-- ... --> <form id=frmReg method=post onsubmit=valRegs() action=memb_area/register.php> Why the function
Form contains show PDF button which sends POST request. This post request shows pdf
form: <form id=defineForm method=POST action=api/test> <fieldset> <legend>Generale</legend> <input type=text name=id size=60 maxlength=60/> <input type=text
Form HTML <form action= method=post class=form-horizontal><div style=display:none><input type=hidden name=csrfmiddlewaretoken value=6b3d58df7bd4f6d10975462aaf3bd42d></div> <input type=hidden name=paper value=5225
Form + element: <form id=form action=default.aspx method=post runat=server> <input type=submit id=submit value=Submit runat=server/> </form>
form.html : <form action="p.py" method="post"> <input type="text" id="id_text" name="name_text" /> <input type="submit" id="id_submit" name="name_submit"
Form (partial): include ../mixins/form-helpers form(action='/users/create', method='post') div.fields fieldset mixin field('text', 'email', 'Email') mixin field('password',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.