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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:56:53+00:00 2026-05-27T04:56:53+00:00

Got the following code: $(‘#next_btn’).click(function() { addUser(); }); //$(‘#next_btn’).click function addUser() { var participant

  • 0

Got the following code:

$('#next_btn').click(function() {
  addUser();
}); //$('#next_btn').click

function addUser() {
  var participant = {};
  var PID = 0;
  PID = FindUserByEmail($('#UserEmail').val());
  // do other things and add this user's data to the participant JSON object
} // function addUser()

function FindUserByEmail(user_email) {
  var url = escape(AJAX_URL_SELECTBYEMAIL + user_email);
  $.ajax({async: true
        , type:'POST'
        , url: url
        , dataType: 'json'
        , success: ajax_find_user_result 
        , error: ajax_error   
        }); // $.ajax
} // function FindUserByEmail(user_email)

function ajax_error(jqXHR, textStatus, errorThrown) {
  alert('X:' + jqXHR.status);
  alert('E:' + thrownError);
} // function ajax_error(jqXHR, textStatus, errorThrown)

function ajax_find_user_result(data) {
  if(data.result) {
    pid = data.result.PID;
    if (pid == 0) {
      alert('User not found');
      return false;
    } else {
      alert(pid);
    } // if (pid == 0)
  } else {
    alert('No results returned');
    return false;
  } // if(data.result)
} // function ajax_find_user_result(data)

The addUser() function is called from the click event. How can I make sure that the function FindUserByEmail returns the value from the ajax call? I am not sure how to do this.

Calling the URL by itself returns correct JSON and a demo returns the correct PID. Just not sure how to do it like above.

  • 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-27T04:56:53+00:00Added an answer on May 27, 2026 at 4:56 am

    How about this?

    function FindUserByEmail(user_email) {
      var url = escape(AJAX_URL_SELECTBYEMAIL + user_email);
      $.ajax({async: true
          , type:'GET'
          , url: url
          , dataType: 'json'
          , success: function(data) {
            if(data.result){
              pid = data.result.PID;
              if(pid == 0) {
                return -1;
              } else {
                return pid;
              }
            } else {
              return -2;
            }
          }
          , error: ajax_error   
          }); // $.ajax
    } // function FindUserByEmail(user_email)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got the following code: $(document).ready(function() { $('a.add-item').click(function() { if ($(this).parent().find('input').attr('value', '0')) { $(this).parent().find('input').attr('value', '1')
I got the following code: <c:forEach var=i begin=1 end=${finalDisccount}> <p><c:out value=${tracksCD} /> Tracks für
I got following code: function test () { this.testFunction = function () { //code
simplified, i've got following code: <a id=123 href=#><span>click</span><span>me</span></a> when i click on 'click' and
I've got following code: $('table.tableElements thead|tbody tr').children().hover(function(){ // How can I do this ↑
I got the following code the works : var library = Assembly.LoadFrom(libraryPath); var namespaces
I got following code in an XHTML-document and every browser saysit is malformed :(
I got following code from net and it looks everything is proper but i'm
Ive got the following code which I hacked together from website examples. It works
I got the following code: char buffer[2047]; int charsRead; do { if(fscanf(file, %2047[^\n]%n%*c, buffer,

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.