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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:31:02+00:00 2026-05-25T23:31:02+00:00

function saveCallerReference(callerReference){ $.getJSON(‘/index.php?r=site/AJAXsaveCallerReference’, function(data) { console.log(data); return data; }); } Given the above, the

  • 0
function saveCallerReference(callerReference){
    $.getJSON('/index.php?r=site/AJAXsaveCallerReference', function(data) {
        console.log(data);
        return data;
    });

}

Given the above, the line “return data;” never gets returned, when the function(data){} exits, where does that return go? I want my outer scope function, saveCallerReference, to return the value from the getJSON(). console.log() is printing correctly so I am getting the data.

  • 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-25T23:31:03+00:00Added an answer on May 25, 2026 at 11:31 pm

    Where do you expect it to be returned to? the function being called is anonymous…

    You need to understand that $.getJSON happens asyncronously so the normal top-down flow does not apply, you need to do whatever you need to trigger whatever you want to do with data inside the callback…

    $.getJSON('/index.php?r=site/AJAXsaveCallerReference', function(data) {
        functionThatDoesWhatYouWant(data);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function checkauth(){ jQuery.getJSON(/users/checkauthjson, null, function(xhr){ if(xhr.success){ return true;}else{ return false;} }); } Obviously, that
function example(){ var quantity = http://www.example.com/index.php?brandid=b%123&quantity=20; quantity = quantity.replace(-what regular expression should i user-,
function contentDisp() { $.ajax({ url : a2.php, success : function (data) { $(#contentArea).html(data); }
function show_destination(country_id,airport_id){ $.ajax({ type: POST, url: function.php, data: country_id=+country_id+&airport_id=+airport_id+&action=destination, beforeSend: function() { $(#loader_destination).html(''); },
function getsession(){ var data = $.get('../session', function(data) { return data; }); return data; }
(function ($) { $.fn.test = function () { console.log('works'); }; })(jQuery); $(document).ready(function () {
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///
function check(id){ var _id = document.getElementById(id); url = test.php?check=1&id= + _id; } i want
function convertDT($TS) { $TS = strtotime($TS); $TS -= date(Z); $newTS = date(Y-m-d\TH:i:s\Z, $TS); return

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.