Assign variable to function
I'm trying to assign IPAddress to using the code below:
- function GetIP() {
- $.getJSON("http://jsonip.appspot.com?callback=?",function(ipadd){
- //var IPAddr;
- IPAddr = ipadd.ip;
- return IPAddr;
- });
- }
- var IPAddress = GetIP()
What am I doing wrong? When I alert(IPAddress); I get undefined. If I alert(IPAddr); within the function, it works just fine.