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

  • SEARCH
  • Home
  • 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 7946021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:01:52+00:00 2026-06-04T01:01:52+00:00

I found, on this site a way to submit a POST form without leaving

  • 0

I found, on this site a way to submit a POST form without leaving the page. In that script, they put instructions on how to have a function take place after the form’s been submitted. Here’s what the script looked like:

$(document).ready(function(){
$form = $('form');
$form.submit(function(){
  $.post($(this).attr('action'), $(this).serialize(), function(response){
  },'json');
  return false;
});
});​

They said, between function(response){ and },'json'); you can specify other JavaScript to take place like alerts etc. after the form’s been submitted. I tried

$(document).ready(function(){
$form = $('form');
$form.submit(function(){
  $.post($(this).attr('action'), $(this).serialize(), function(response){
$('form').hide();
  },'json');
  return false;
});
});

Unfortunately, that does not work, can anybody tell me why? I’ve set up a jsFiddle. Please help. Thanks.

  • 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-04T01:01:54+00:00Added an answer on June 4, 2026 at 1:01 am

    Using $.post, the “function(response)” is only called AFTER a successful result, so you have been misinformed about doing work within this function while the server is processing the request.

    To continue processing after sending the request to the server, place the $(‘form’).hide() after the $.post call:

    $form.submit(function(){
      $.post(
        $(this).attr('action'), $(this).serialize(), 
        function(response){
        }
        ,'json'
      );
      $('form').hide();
      return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this interesting site, that helps me understand derivatives, http://www.numberempire.com/derivatives.php , It seems
I was creating a website http://tapasya.co.in and i found that this site has some
I found this site that allows to convert RSS feeds into json. It also
I'm working on a sample i found on this site: http://kevinmusselman.com/blog/2009/02/access-webcam-with-flash/ it captures the
I've tried all the time calculating examples I found on this site but somehow
I found this in Ryan Bates' railscast site, but not sure how it works.
I found this code on a hacked site, what does it do exactly? It
I just started a new Typo3 4.6 site and I found this weird line
I've found no other stackexchange site to ask this question so I present it
I have a site that enables users to post messages to a forum. At

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.