0

Its a bit strange. I am making a bitly api call and it returns undefined for all the calls, but if I add an alert() right before I get the link variable, it returns the correct link.

Now if I add the alert here :

function getBitlyLink(){
    alert(bitlyLink);
    return bitlyLink;
}

I get the correct links and not undefined. What exactly is that alert box doing??

imgr8
  • 501
  • 4
  • 11
  • 25

1 Answers1

3

Your code is not being executed synchronously. Pass a callback to your getBitlyLink() function.

alex
  • 479,566
  • 201
  • 878
  • 984
  • which would be like function getBitlyLink(callback)?? and then callback(bitlyLink); ? How do I make the call to it then? – imgr8 Jun 09 '11 at 06:43