I am working in jQuery Mobile and PhoneGap for iPhone and Android!!
In my application I need to find out the IP address of the mobile device and POST to the server to get the details of residence and currency details from the server as its result (in JSON format).
I created some code; but it contains an external link, http://jsonip.appspot.com/?asp.net and its code looks like this:
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" language="javascript">
function myIP() {
if (window.XMLHttpRequest)
xmlhttp = new XMLHttpRequest();
else
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET","http://jsonip.appspot.com/?asp.net",false);
xmlhttp.send();
hostipInfo = xmlhttp.responseText;
obj = JSON.parse(hostipInfo);
document.getElementById("IP").value = obj.ip;
document.getElementById("ADDRESS").value = obj.address;
}
</script>
</head>
<body onload="myIP()">
IP: <input type="text" id="IP" name="IP" />
ADDRESS: <input type="text" id="ADDRESS" name="ADDRESS" />
</body>
</html>
But I am looking for a solution without using any server-side calling (http://jsonip.appspot.com/?asp.net) and server-side coding. And only using JavaScript which is OK on mobile devices. Is there a solution for that?
Or do I need to follow the given example which I checked?