Hi, I'm doing a small html with your javascript to show me my ip, the code is as follows:
<HTML>
<HEAD>
<script type="text/javascript">
(function(loading, success){
var xhr = XMLHttpRequest !== undefined
? new XMLHttpRequest()
: new ActiveXObject('Microsoft.XMLHTTP');
loading.apply(null, []);
xhr.open('get', 'https://api.ipify.org/?format=json', true);
xhr.onreadystatechange = function()
{
if(xhr.readyState === 4)
{
success.call(null, JSON.parse(xhr.responseText));
}
}
xhr.send();
}(function()
{
document.getElementById('my-ip').innerHTML = 'cargando ip...';
}, function(response)
{
document.getElementById('my-ip').innerHTML = response.ip;
}));
</script>
<script type="text/javascript" src="https://api.ipify.org/?format=jsonp&callback=get_ip"></script>
</HEAD>
<BODY>
mi ip es: <strong id="my-ip"></strong>
</BODY>
</HTML>
But it does not work, it returns the following:
However, in the example, it worked: link
How could I fix it?