Skip to content

Instantly share code, notes, and snippets.

@bhandarisaurav
Created December 17, 2018 09:59
Show Gist options
  • Save bhandarisaurav/83ccd91f1401cc1734077e40d3f9a3d7 to your computer and use it in GitHub Desktop.
Save bhandarisaurav/83ccd91f1401cc1734077e40d3f9a3d7 to your computer and use it in GitHub Desktop.
Get System's Public IP Address
$(document).ready(function () {
var xmlhttp = new XMLHttpRequest();
var url = "http://ipecho.net/plain";
xmlhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
IP = this.responseText;
// IP variable stores the PUBLIC IP address of the system
//for eg 110.44.116.42
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment