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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:27:48+00:00 2026-06-10T15:27:48+00:00

I am trying to make this ajax request function work but netbeans is giving

  • 0

I am trying to make this ajax request function work but netbeans is giving a warning that the following function does not always return a value. Can anyone please help.

function fpform(){
    var response='';
    var fpemail = $('#frgtpwd').val();
    //var fpemail = document.getElementById('frgtpwd').value;

    if (fpemail == ""){
        $('span#fperror').text("insert your emal address");
        //document.getElementById('fperror').innerHTML = "Insert your email address";
        return false;
    } else {
        var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (filter.test(fpemail)==false) { 
            $('span#fperror').text("Email address is not in valid format");
            //document.getElementById('fperror').innerHTML = "Email address is not in valid format";
            return false;
        } else {
            $("#loader").html('<img src="images/ajax-loader.gif" />');
            $.post("forgot_password_process.php", {
                email:fpemail
            }, function(response){
                response = response.trim();
            }).success(function () {
                if (response == 'yes'){
                    $("#fperror").html('<font color="green"><b>Your password has been reset now and emailed to you </b></font>');
                    $("#loader").hide('<img src="images/ajax-loader.gif" />');
                    return true;
                } else {
                    alert("your email address was not found");
                    $("#loader").hide('<img src="images/ajax-loader.gif" />');
                    $("#fperror").html('<font color="black"><b> Email address was not found in database!</b></font>');
                    return false;
                } 
            });
        }
    }
}
  • 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-10T15:27:50+00:00Added an answer on June 10, 2026 at 3:27 pm

    The return true; statement in your code is not returning from fpform. It is instead returning from the callback function given to .success(). By the time this function is executed, the outer function, fpform, has long since returned. The only way to “return” from a function using ajax is with a callback.


    Before I give you any code, you’ve made a bunch of other mistakes:

    1. Your email regex, /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, fails on my email address. + is a valid character as well. Consider not validating email addresses with regex.

    2. $("#loader").hide('<img src="images/ajax-loader.gif" />') does not work. At all. You want $("#loader").empty()

    3. The variable response you declare at the top is shadowed by your argument response in one of your anonymous functions, making response = response.trim() have no effect whatsoever.


    function fpform(callback) {
        var fpemail = $('#frgtpwd').val();
    
        if (fpemail == ""){
            $('span#fperror').text("insert your email address");
            callback(false);
        } else {
            var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            if (filter.test(fpemail)==false) { 
                $('span#fperror').text("Email address is not in valid format");
                callback(false);
            } else {
                $("#loader").html('<img src="images/ajax-loader.gif" />');
                $.post("forgot_password_process.php", {
                    email:fpemail
                }).success(function(response) {
                    response = response.trim();
                    if (response == 'yes'){
                        $("#fperror").html('<font color="green"><b>Your password has been reset now and emailed to you </b></font>');
                        $("#loader").hide('<img src="images/ajax-loader.gif" />');
                        callback(true);
                    } else {
                        alert("your email address was not found");
                        $("#loader").hide('<img src="images/ajax-loader.gif" />');
                        $("#fperror").html('<font color="black"><b> Email address was not found in database!</b></font>');
                        callback(false);
                    } 
                }).error(function() { callback(false); });
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is essentially that I am trying to make a universal Ajax function
I am trying to make two ajax requests in parallel using jQuery like this:
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I am trying to make this sample program work (defn foo ([x] (foo x
I'm trying to make this regex ^(?!\-\-\sRoaming) to match with -- Roaming but it
I'm trying to make this request to the RunKeeper API : GET /user HTTP/1.1
I am trying to make this button using CSS3: But my button looks like
I'm trying to make this fragment work: Version History --------------- These are the versions
So, I'm trying to make cross-site AJAX request from my own script to the
I am trying to make a request to the yahoo wheather forcast like this

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.