Global Variable Scope: Random Quote Generator

Trying to set my Tweet link/button to pass the quote information to the tweet. I plan to pass the $.param(quote) but just wanted to pass the variable ‘quote’ for now that was set in the getJson call. However in my code it says that ‘quote’ is undefined.

  var qodAPI = "";
  var quote;
  var author;

  function displayQuote(data){
  quote = data.quote;
  author =;

  $("#quote").html(quote + "<p>&mdash; " + author + "</p>")

  function newQuote(){
    $.getJSON(qodAPI, displayQuote);

  function tweetQuote(){
    $('#tweetButton').attr("href", "" + quote)

  //new quote when page loaded.



Never mind. I moved setting up the tweet link into the callback function.