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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:49:48+00:00 2026-05-24T15:49:48+00:00

Possible Duplicate: jquery ajax call taking too long or something for some reason this

  • 0

Possible Duplicate:
jquery ajax call taking too long or something

for some reason this ajax call

        $('#new_user').submit(function(e){
            $.ajax({
                type: 'post',
                url: "/validate_paypal",            
                dataType: 'json',
                async: false,
          data: {email : $('#user_paypal_email').val()},
              success: function( data ) {
                if (data.response["valid"] == false){
                        $('#user_paypal_email').closest('.field').addClass('fieldWithErrors');
                        $('.error_messages').remove();
                        $('<span class="error_messages" style="color:#E77776;margin-left: 10px;">This is not a valid paypal email address</span>').insertAfter('#user_paypal_email');
                        return false;
               }
                }
        });

});

is still submitting the form even after prints out my error and my return false….why is that

  • 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-24T15:49:49+00:00Added an answer on May 24, 2026 at 3:49 pm

    $.ajax is a function call which defines an AJAX callback then and the .submit function ends. Separately (asynchronously) the AJAX call is made and your success function then returns false to basically nothing since .submit has already finished.

    What you really want to do is halt the form submission process, waiting for the AJAX call to finish, then decide if it should continue. This can be achieved by completely stopping the form submission the first time, then manually resubmitting it once you’ve got the AJAX callback. Of course the trick is how do you know it’s valid? You could throw a value on the submit element.

    Example:

    $('#new_user').submit(function(e){
        var submitElem = $(this);
    
        // Check for previous success
        if (submitElem.data('valid') !== true) {
            $.ajax({
                type: 'post',
                url: "/validate_paypal",            
                dataType: 'json',
                async: false,
                data: {email : $('#user_paypal_email').val()},
                success: function( data ) {
                    if (data.response["valid"] == false) {
                        $('#user_paypal_email').closest('.field').addClass('fieldWithErrors');
                        $('.error_messages').remove();
                        $('<span class="error_messages" style="color:#E77776;margin-left: 10px;">This is not a valid paypal email address</span>').insertAfter('#user_paypal_email');
                        return false;
                    } else {
                        // If successful, record validity and submit (allowing to continue)
                        submitElem
                            .data('valid', true)
                            .submit();
                    }
                }
            });    
            return false;
        } else {
            // Fall through
            return true;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: using jquery $.ajax to call a PHP function I need to call
Possible Duplicate: jQuery: How to stop AJAX function escaping JSON string used to POST
Possible Duplicate: Show Page Loading Spinner on Ajax Call in jQuery Mobile Is it
Possible Duplicate: jQuery ajax error function I am trying to replace a global ajax
Possible Duplicate: Multiple ajax calls inside a each() function.. then do something once ALL
Possible Duplicate: Submit a form using jQuery $('#form') Supposed the jQuery Object of the
Possible Duplicate: jquery/ajax load new content when available i have a table named news
Possible Duplicate: jquery validate & ajax.beginform I'm trying to use the jQuery validate plugin
Possible Duplicate: Kill Ajax requests using JavaScript using jQuery Here is the simple code
Possible Duplicate: Cross-Domain Requests with jQuery $(function () { (function getFeed() { $ .get('http://feeds.bbci.co.uk/news/world/rss.xml')

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.