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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:48:24+00:00 2026-06-15T14:48:24+00:00

When a user submits a form I want ajax to check if the email

  • 0

When a user submits a form I want ajax to check if the email address exists using the following

$.post("checkemail.php", {email: email})

Depending on the value I will choose to submit or not (preventdefault)

However the form is submitting before returning the value.
I have tried the following:

$.when($.post("inc/checkemail.php", {email: email})).done(function(result) {
 // code here
}

However I can’t seem to get this right. What am I doing wrong?

Thanks for any help in advance, you guys are always great!

  • 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-15T14:48:25+00:00Added an answer on June 15, 2026 at 2:48 pm

    Stopping the default behavior should always happen regardless of what the post returns. Only on ‘done’ should you decide to submit the form:

    $('form').on('submit', function(e) { 
      e.preventDefault()
      $.post('checkemail.php', {email: email})
      .done( function(result){
        // check response to see if the email does not exist
        $('form').off('submit') // We don't want to stop the submission anymore.
        $('form').submit()
      })
    })
    

    edit: Also, note that $.post returns a type of deferred object, so the $.when call is unnecessary.

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

Sidebar

Related Questions

I am using Jquery AJAX to post a form on my page. I want
I'm displaying a message (#final_msg) after the user submits the form. What I want
I'm using the ajax technique in combination with php and I want to know
If a website user submits an HTML form with: (1) a post method; (2)
I have a PHP email form and the user enters their email and it
I want to check the value enter in the form by user. i have
I m using Ajax call to check whether a user has logged in or
I'm trying to return a callback from an AJAX submitted form. The user submits
When a User Submits the form i want to stop the default behavior of
I am using jQuery AJAX and ASP.Net web methods. I need to check user

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.