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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:31:18+00:00 2026-05-23T17:31:18+00:00

I have looked through here and I realize it doesn’t look like getJSON returns

  • 0

I have looked through here and I realize it doesn’t look like getJSON returns anything but a object that is unusable. The problem I am having is that I am trying to edit someone else’s code to pull picture from flickr. I am trying to make a function that will return the description of the pictures. I know that it doesn’t return information however there has to be a way to update a global variable or somehow pass off the information i need into another variable to return to his function. This is the jist of what I have so far.

  function add_description(n){

    var img_id = String(n);


    var textInfo ="";
$.getJSON('http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=36c8b00c47e8934ff302dcad7775d0a2&photo_id='+img_id+'&format=json&jsoncallback=?', function(data ){


                 textInfo = String(data.photo.description._content);
                alert(textInfo);
                return textInfo;           

            })


}

this is the code I tried after your updates George. Thanks!

 var testObj=$.getJSON('http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=36c8b00c47e8934ff302dcad7775d0a2&photo_id='+img_id+'&format=json&jsoncallback=?', function(data ){



                 textInfo = String(data.photo.description._content);
                alert(textInfo);
                return textInfo;



            })
  • 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-23T17:31:19+00:00Added an answer on May 23, 2026 at 5:31 pm

    The first step is to assign the results to the textInfo variable:

    $.getJSON(...) {
        textInfo = String(data.photo.description._content);
    

    The $.getJSON() call is asynchronous, so your code return textInfo; probably runs before the $.getJSON() call completes. Therefore, the textInfo variable is still an empty string. You will need to call the other code from within the $.getJSON() call, or delay execution of the return until the asynchronous call completes.

    This answer is based on the similar answer found here.

    EDIT (based on your question update):

    You will not be successful including the return statement within scope of $.getJSON(). You can assign the result to the variable textInfo as you have done, and that value will be available when $.getJSON completes.

    However, you must ensure that the call has completed before attempting to accessing the value. You can use setTimeout(), which seems messy, or you can substitue $.ajax() for your $.getJSON() call so you can use the ‘async = false’ option. This will force the call to complete before execution continues, allowing the variable to be populated before returning it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked through various answers here, but am still unable to figure it
I looked through the questions here but didn't find one that suited my case.
have looked through many posts here on SO, and haven't found any that address
I've downloaded the Windows Media Center SDK and have looked through the documentation, but
I have looked through the other questions on here, and on other forums. The
I have looked through replacing colors in an image but cannot get it to
I have looked through as many previous questions as possible but never saw a
I have looked through the site and couldn't find a question that solved my
I've looked through the various questions on unit testing but can't find one that
Ok.. I have looked through this site and just can't seem to find the

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.