Javascript function returning undefined
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??
Your code is not being executed synchronously. Pass a callback to your getBitlyLink()
function.
精彩评论