如何使用jquery获取本地PC ipaddress [英] How to get local PC ipaddress using jquery
问题描述
Hello guys
我正在尝试使用以下来获取本地IpAddress
$ .getJSON( http://jsonip.com/?callback=?,功能(数据){
Ip = data.ip;
});
使用Jquery我得到Ipaddress
但问题是这个ipaddress与我在CMD中使用的Ipaddress不同
命令ipconfig.i想要我在cmd中获得相同的ipaddress
请帮帮我
谢谢提前
我尝试过:
$ .getJSON( http://jsonip.com/?callback=?,功能(数据){
Ip = data.ip;
});
Hello guys
I am trying to get Local IpAddress using following
$.getJSON("http://jsonip.com/?callback=?", function (data) {
Ip = data.ip;
});
using Jquery and i get Ipaddress
but the thing is that this ipaddress is different from the Ipaddress i got in CMD using
command ipconfig.i want same ipaddress which i get in cmd
please help me in that
Thanks in Advance
What I have tried:
$.getJSON("http://jsonip.com/?callback=?", function (data) {
Ip = data.ip;
});
推荐答案
.getJSON(http://jsonip.com/?callback=?,函数(数据){
Ip = data.ip;
});
使用Jquery我得到Ipaddress
但问题是这个ipaddress是不同的fr我使用
命令ipconfig.i获得了我在CMD中获得的Ipaddress想要在cmd中获得相同的ipaddress
请帮助我
预付谢谢
我尝试过:
.getJSON("http://jsonip.com/?callback=?", function (data) {
Ip = data.ip;
});
using Jquery and i get Ipaddress
but the thing is that this ipaddress is different from the Ipaddress i got in CMD using
command ipconfig.i want same ipaddress which i get in cmd
please help me in that
Thanks in Advance
What I have tried:
.getJSON(http://jsonip.com/?callback=?,功能(数据){
Ip = data.ip;
});
.getJSON("http://jsonip.com/?callback=?", function (data) {
Ip = data.ip;
});
正确。
您认为IP地址取决于您所询问的位置。
你通过IPCONFIG获得的地址是本地网络地址,并且(几乎可以肯定)是192.168.xxx.yyy
通过查询互联网获得的地址是将您的网络连接到互联网的路由器的IP地址,永远不会以192.168开头,因为它绝对是为本地网段保留的。
并且互联网IP地址不是您要查询的计算机的地址:它是路由器的地址,并且由使用相同互联网连接的所有设备共享。
Correct.
What you think of as "the IP Address" depends on where you are asking.
The address you get with IPCONFIG is the local network address, and will (almost certainly) be "192.168.xxx.yyy"
The address you get by querying the internet is the IP Address of the router which connections your network to the internet, and will never, ever, start with "192.168" as that is absolutely reserved for local network segments.
And the internet IP address is not the address of the computer you are querying from: it is the address of the router, and is shared by all devices using the same internet connection.
这篇关于如何使用jquery获取本地PC ipaddress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!