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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:27:21+00:00 2026-05-26T16:27:21+00:00

[name=AddClientSubmit] … is the submit button on a form. The $.POST sends the forms

  • 0

[name=AddClientSubmit] … is the “submit” button on a form.

The $.POST sends the forms data and the post script returns a json response with an error message in it.

If there is no error message I want to return the click function as true so the form is submitted and false if there is an error.

Problem with my script below is javascript doesn’t wait for the $.POST to fully finish and the submitForm value is never set so the form automatically is submitted.

 $('[name="addClientSubmit"]').click(function() {
    var submitForm = false;
    var buttonObj = $(this);
    buttonObj.hide();

    $.post(
        '/jquery/scripts/contacts_clientAddEdit.php',
        $('#addClientForm').serialize(),
        function(json) {
            if(json.error == '') {
                submitForm = 'yes';
            } else {
                jAlert(json.error, 'Error', function() {
                    buttonObj.show();   
                });
                submitForm = 'no';  
            }
        },
        'json'
        );

        if(submitForm == 'yes') { return true; }
        if(submitForm == 'no') { return false; }
     });
  • 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-26T16:27:21+00:00Added an answer on May 26, 2026 at 4:27 pm

    The problem is that the $.post method is asynchronous so it will return before the submission is complete. There is a way to turn this off but it causes the browser to hang and sometimes behave to the user as if it has crashed.

    Instead of creating two separate posts, one for this AJAX functionality and one for the form why not combine them? This will both resolve your issue and result in a quicker response time for the user.

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

Sidebar

Related Questions

The name view model suggests that it models the data for the view. That
My name is Juan I'm from Spain and this is my first post. Thank
Name of the option tells something but what Visual Studio/compiler really do and what
Name the design considerations in deciding between use of a singleton versus a static
Name: <%= Html.TextBox(txtName, 20, new { @class = hello }) %> I want that
The name of a temporary table such as #t1 can be determined using select
var name = 'Mike'; var person = { name: 'John', welcome: function(){ var name
Class name: MyAssembly.MyClass+MyOtherClass The problem is obviously the + as separator, instead of traditionnal
SELECT name FROM sys.databases -- this can list all database name in the server
class Name implements Runnable { public void run() { for (int x = 1;

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.