I have following Code for Get IP address i want to store that data.ip with global scope that i can access anywhere in file.
<script>
ip = null;
$.getJSON("http://jsonip.appspot.com?callback=?",
function(data){
ip = data.ip;
alert(ip); //return ip address correctly
});
alert(ip); //undefined or null
</script>
This will set the IP Address to a hidden input field.