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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:08:08+00:00 2026-06-02T00:08:08+00:00

I am using following method to call the php: function validateEmaiAjax(email){ val = null;

  • 0

I am using following method to call the php:

function validateEmaiAjax(email){
    val = null;
    $("#warning").load("https://localhost/Continental%20Tourism/register_ajax.php",{email: email}, function(rspns, stat, xml){
        val = rspns;
    });

    if(val == ".")
        return true;
    else {
        return false;
    }
}

my php code is:

<?php
    $dbc = mysqli_connect("localhost","root","pass","continental_tourism") OR die(mysqli_connect_error());

    $email = $_REQUEST['email'];

    $query = "SELECT email FROM customer_info WHERE email = '$email' ";

    $r = mysqli_query($dbc, $query) OR die(mysqli_error($dbc));

    if(mysqli_num_rows($r) > 0)
        echo "Email address exists!";
    else
        echo ".";   
?>

Basically this do check the database and if email exists shows “Email address exists!” if not I want to return true(so I echo “.” and compare it). The weird thing is if i put a break point using firebug near if(val == ".") program works correctly and returns true. If I remove that break point function always return false. I cant understand why this happens. 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-02T00:08:10+00:00Added an answer on June 2, 2026 at 12:08 am

    The reason you have this problem is because you have performed an asynchronous request. This means that the if(rspns == ".") will be reached before the response has been received from the server, and the result will always be false.

    In order to wrap this code in a function the returns a boolean and does not require a callback function (a blocking procedure) you will need to use a synchronous request:

    function validateEmaiAjax(email) {
    
      // This is the correct way to initialise a variable with no value in a function
      var val;
    
      // Make a synchronous HTTP request
      $.ajax({
        url: "https://localhost/Continental%20Tourism/register_ajax.php",
        async: false,
        data: {
          email: email
        },
        success: function(response) {
          // Update the DOM and send response data back to parent function
          $("#warning").html(response);
          val = response;
        }
      });
    
      // Now this will work
      if(val == ".") {
        return true;
      } else {
        $("#warning").show();
        return false;
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following method which I am using to load ActiveX control dynamically, Dim
Using PHP's Image and GD functions you can use the following method to finally
I am trying to send email using the following method in my action class:
I am using the following method to reverse geocode a google maps latlng: [GClientGeocoder.getLocations(address:String,
I am using the following method to basically create a JSON string. var saveData
I am using the following method to get the time of the video with
I'm using the following method in my code: - (NSMutableArray *) newOrderedArray:(NSMutableArray *)array ByKey:(NSString
I am using the following method to serialize a date as a string private
I'm using the following method to open my SQLite db. private void open() {
We are using the following method to write the log to log file. The

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.