Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Function returns undefined

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #234778
    mikelf
    Participant

    Hello, i got this function

    function get_twitchpic(ch_name){
    var api = “https://api.twitch.tv/kraken/channels/” + ch_name;
    $.getJSON(api, function(json) {
    var logo= json[“logo”];
    return logo;
    });
    }

    located in function.js; If i put a console.log before the return it gives me the correct link, however, when i call that function from index.php and store it like this:
    var pic = get_twitchpic(‘liftingnerdbro’);
    it says that pic is undefined. can somebody help me?

    #234786
    Shikkediel
    Participant

    Let me refer to this (third answer looks easiest)…

    http://stackoverflow.com/q/31129/3168107

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.