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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:52:51+00:00 2026-06-11T15:52:51+00:00

As my framework grows i decided to split it into files, instead of leaving

  • 0

As my framework grows i decided to split it into files, instead of leaving it in the main design file. However by doing that the return of a function doesn’t return any value.

data isn’t empty – if i alert the values in the js file they are there!

The functions:

1st the function in .js file (is included before the execution)

             var lock_get = 0;
             function get_data(data, destination) 
             {

                if (lock_get == 0)
                {
                    lock_get = 1;
                    $.ajax({
                        type: "POST",
                        url: destination,
                        async: true,
                        data: data,
                        success: function(data) 
                        {
                            lock_get = 0;
                            if (data)
                            {
                                return data;
                            }
                        }
                    });
                }
             };

So and here is the execution part:

    var test = get_data(data, destination);
    notice(test);

and test is empty… I already tried different ways for writing but I guess i missunderstood the possibilities of js?

  • 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-11T15:52:52+00:00Added an answer on June 11, 2026 at 3:52 pm

    You can’t do that : as the call is asynchronous, the get_data function can’t return the result of the ajax call.

    What you should do is provide a callback to the get_data function and handle the result in the callback.

    function get_data(data, destination, callback) 
             {
    
                if (lock_get == 0)
                {
                    lock_get = 1;
                    $.ajax({
                        type: "POST",
                        url: destination,
                        async: true,
                        data: data,
                        success: function(data) 
                        {
                            lock_get = 0;
                            if (data && callback)
                            {
                                callback(data);
                            }
                        }
                    });
                }
             };
    

    And call it like that :

    get_data(data, destination, function(test){
       notice(test);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Akka framework recommends using typed actor only for interacting with external code. However, standard
.NET framework 3.5 introduces Action and Func<> predefined delegate types that are very handy.
I'm trying to understand some fundamental best practices using Entity Framework. My EDM design
I am doing some maintenance on a database for an application that uses the
.framework bundles contain header files which are also included when then framework is shipped.
.framework/MapKit, file was built for i386 which is not the architecture being linked (armv6)
I have a self-hosted WCF service (v4 framework) that is exposed through a HttpTransport
I am integrating growl into my Objective-C app. However If I build and run
I have written a small webapp using the flask framework that involves plotting using
I've implemented firePHP with ZF (http://www.christophdorn.com/Blog/2008/09/02/firephp-and-zend-framework-16/) which works like a charm. However what I'm

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.