开发者

How to get gethostbyname by using jquery [duplicate]

开发者 https://www.devze.com 2023-04-04 19:16 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Can I lookup the IP address of a hostname from javascript?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Can I lookup the IP address of a hostname from javascript?

Hi is there开发者_运维百科 a jquery eqivalent to the php gethostbyname() function?


No, but you could make an ajax call to your server. The php on the server would then find it for you and return an answer. Note the following is untested.

Jquery

$.getJSON('gethostbyname.php', function(data){
    alert('Php said: ' +  data.ip);
});

-- EDIT --

Php

<?php
    $ip = gethostbyname('www.foo.com');
    $data.ip = $ip;
?>

If you wan't the domain to be dynamic you will have to use JQuery ajax


Try the hostname property of the location object in your JavaScript:

window.location.hostname
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号