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 7168679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:49:40+00:00 2026-05-28T14:49:40+00:00

Suppose I have a form : <form id=myForm method=POST action=/something/somewhere> <input type=text name=textField />

  • 0

Suppose I have a form :

<form id="myForm" method="POST" action="/something/somewhere">
   <input type="text" name="textField" />
   <input type="submit" name="foo" value="bar" />
</form>

the /something/somewhere action does not return a complete html page, but just a fragment.

I would like to let the submit button do its posting job, but catch the result of this post and inject it somewhere in the DOM.

The jQuery submit happens before the form is actually submitted. An exemple of how it could work is:

$('#myForm').posted(function(result)
{
    $('#someDiv').html(result);
});

Any way to do this?

  • 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-05-28T14:49:42+00:00Added an answer on May 28, 2026 at 2:49 pm

    Description

    You can use the jQuery .post() and .serialize() method for that.

    .post() Load data from the server using a HTTP POST request.

    .serialize() Encode a set of form elements as a string for submission.

    .preventDefault() If this method is called, the default action of the event will not be triggered. In your case the normal submit.

    Sample

    Html

    <form id="myForm" method="POST" action="/My/MyActionMethod">
       <input type="text" name="textField" />
       <input type="submit"/>
    </form>
    
    <div id="someDiv"></div>
    

    jQuery

    $(function() {
      $('#myForm').live('submit', function (e) {
         var form = $(this);
         e.preventDefault();
         $.post(form.attr('action'), form.serialize(), function (result) {
            $('#someDiv').html(result);
         });
      });
    });
    

    MVC Controller

    public class MyController : Controller
    {
        [HttpPost]
        public ActionResult MyActionMethod(FormCollection forms)
        {
            // do something with forms["textField"];
            return Content("<b>Hello World!</b>");
        }
    }
    

    If you have trouble getting it to work (thanks IE), try

    event.preventDefault ? event.preventDefault() : event.returnValue = false;
    

    More Information

    • jQuery.post()
    • jQuery.serialize()
    • event.preventDefault()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

suppose I have a form: <form id=someform action=some.php method=get> <input type=text name=somename /> <input
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input
Suppose I have a form like this: <form id='myform'> Favorite colors? <input type='checkbox' name='color'
so suppose I have 3 forms <form name=form1> <input name=input></input> <submit></submit> </form> <form name=form2>
If I have an HTML form, let’s say... <form id='myform'> <input type='hidden' name='x' value='y'>
I have a form that is suppose to be a POST to CREATE action
Suppose I have a form on a page at this location... http://mydomain.com/myform.htm And the
Suppose you're building an HTML form and you want to have 2 or more
I have a PictureBox control on a Form that is supposed to draw something
Suppose that I have a simple form in my page like this : <form

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.