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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:02:04+00:00 2026-05-13T16:02:04+00:00

I stripped all my logic out of my jquery plugin for this question, but

  • 0

I stripped all my logic out of my jquery plugin for this question, but my problem is that when I call my function checkValidationName, it does it’s thing and sets name = to true. Then when i try to compare it right after where i called it, the value is false. Why is this?

 (function($){  
       $.fn.validate = function() {     

            var name = false;

            $('.submitBtn').click(function() {


                 $.fn.validate.checkValidationName(nameValues);


                 **console.log("name = "+name); **//but this prints out "false"****
                 //shouldn't this be true since name returned true in the actual function??


                 }
            });

            $.fn.validate.checkValidationName = function(id) {
                 $.post("PHP/submitButtonName.php", {checkValidation: id},
                     function(data) {

                          **console.log("name = "+name); **//this prints out "true"**** 
                          //name is equal to true here

                     }, "json");
            };

      }    
 })(jQuery);  
  • 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-13T16:02:04+00:00Added an answer on May 13, 2026 at 4:02 pm

    That’s because the AJAX requests are asynchronous and right after you called checkValidationName, it hasn’t finished yet. You need to do the comparison in the callback.

    You can make checkValidationName take a callback and call it with the result when validated:

    (function($){
        $('.submitBtn').click(function() {
            $.fn.validate.checkValidationName(nameValues, function(valid) {
                console.log(valid);
            });
        });
    
        $.fn.validate.checkValidationName = function(id, callback) {
             $.post("PHP/submitButtonName.php", {checkValidation: id},
                 function(data) {
                    var valid = data.foo; // or however you determine that
    
                    callback(valid); // call callback
                 }, "json");
        };
    }(jQuery));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all! I have a database table that looks somewhat like this (stripped for
I have several paragraphs of text that are being stripped of all of their
I have this horribly stripped delphi code that basically login to server, save cookie
Given that I have this resultset structure (superfluous fields have been stripped) Id |
This problem is keeping me busy all week and I find little to nothing
I want to test the following logic (this is obviously a stripped-down version of
Below is a jquery script I am working on, I have stripped down all
I have the following code which I stripped out of any non-essential lines to
I posted this once, but I was a bit too vague in my information,
I have a site that allows public access to some pages, but requires a

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.