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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:50:29+00:00 2026-05-25T21:50:29+00:00

Here is my code in my jquery/javascript that is performing the ajax request… else

  • 0

Here is my code in my jquery/javascript that is performing the ajax request…

else {
        $.post("http://www.example.com", {email: val}, 
        function(response){
            finishAjax('email', response);
        });
    }
        joinAjax('cemail');
}
if (id == 'cemail') {

        $('#cemailMsg').hide();
    var email = $('#email').val();
        if (errors.email == false) {

                if (val != email) {

The ajax request is working and all is good, but the next if statement where the argument is:

if (errors.email == false) {

I need to be able to set this variable from my ajax.php file to either true or false and return it so the javascript can read it. Is this possible??
It is because the ajax is checking if the username is available or not, if not available a form error would be true preventing the form submitting, or if false then the user can submit.

My ajax.php file:

if ($_REQUEST['email']) {

$q = $dbc -> prepare("SELECT email FROM accounts WHERE email = ?");
$q -> execute(array($_REQUEST['email']));
if (!$q -> rowCount()) {

    echo '<div id="emailMsg" class="success">Email OK</div>';
    exit();
}
else {

    echo '<div id="emailMsg" class="error">Email taken</div>';
    exit();
}
}
  • 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-25T21:50:30+00:00Added an answer on May 25, 2026 at 9:50 pm

    Why not have your ajax.php return an associative array like so:

    echo json_encode(array("email" => "success", "key2" => "val2"));
    

    And then use

    var responseJSON = JSON.parse(response);
    

    In the $.post callback function to read the response and act accordingly. You can generate the appropriate markup (divs or whatever) client-side and insert it.

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

Sidebar

Related Questions

Using the checkbox styling system here (with a few slight modifications): http://blogs.digitss.com/javascript/jquery-javascript/jquery-fancy-custom-radio-and-checkbox/ I have
I am using cody sherman's javascript code here: http://codysherman.com/tools/infinite-scrolling/code I am also using a
I am using the jquery tooltip and here is the code for it Javascript
I'm having some trouble with the jQuery hover method. Here's the relevant JavaScript code:
I am using ASP.NET page methods with jQuery. Here is my code, $.ajax({ type:
I have this html code that i want to edit with jQuery. Here is
So taking a look at the API doc page here: http://developers.facebook.com/docs/reference/javascript/FB.api I'm wondering if
Here is javascript code (jquery) for adding a row of images: var tr =
I have some JavaScript/jQuery code that watches for the changed event on a checkbox:
The thing I'm trying to have is a JQuery/JavaScript code that will automatically pass

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.