title: Return values from an Ajax function
body: <p>I am trying to create a block of text that will update itself when the text changes from a Json string.</p>
  
  <p>Basically I started with:</p>
  
  <pre><code>function streamSong(index) {
          if (!isUndefined(myPlaylist[index].title))
              return myPlaylist[index].title;
          else return '';
      }
  </code></pre>
  
  <p>then modified it to look like this:</p>
  
  <pre><code>function streamSong(index) {
          var currentSongName = 'here';
          if (!isUndefined(myPlaylist[index].title)) {
                          var intervalFunc = function(){
                              var jsonData = null;
                              $.ajax({
                              url: 'http://www.thesite.com/pullJson.php?stream=rapstation',
                              dataType: "json",
                              data: { get_param: 'employees' },
                              success: function (data) { 
                                currentSongName = 'now here';
                              },
                              error: function (data) { 
                                currentSongName = 'not working';
                              }
                            });
                          };
                          setInterval (intervalFunc, 60000);
                          setTimeout (intervalFunc, 1);
                          return currentSongName;
          }
          else return 'no title';
      }
  </code></pre>
  
  <p>The first function fired off fine and returned my Stream Title.
  The second function fires off, but I never am able to modify the value of currentSongName.</p>
  
  <p>I am still a bit new to Javascript and ajax so excuse my ignorance, but I obviously want to ultimately set the value of currentSongName to the Json value I retrieve, but for now I would just like it to be able to change values on a timer.</p>
  
  <p>Am I going about this all wrong?</p>