在延迟时设置Whois脚本


Setting up an Whois -script on a delay

所以我遇到了这个问题,因为我有一个数据库客户端,而现在的情况是,当页面加载时,它会为数据库表中的每一行生成部分,其中包含域名和相应的PHP IP地址。

除此之外,我还有一个"附加信息"按钮,它从phpwhois-neneneba API网站加载信息,它扫描相应的地址并返回关于该网站的所有whois-information(创建日期、过期日期等)

所以我想把这个系统从一个按钮改成一个即时系统,但似乎做不到。

我认为问题在于页面试图在获得信息之前加载所有脚本

//This is the Jquery for the button press, which loads the additional information

 $(document).ready(function showresult(){
  $(".showinfo").click(function(){

        site = ($(this).closest('.row').find('li:first').text());
      $('.result').load('http://localhost/database/phpwhois-4.2.2/whois.php?query='+site+'&output=nice #result  ');
      $('.result').show();
      $('.hideinfo').show();
      $('.showinfo').hide();
          });  
  });

然后是PHP

print "<div class='row'>";
print "<li class='names'>".$row['name']."</li>";
print "<li class='add'>".$row['add']."</li>";
print "<br><br>";
print "<div class='addinfo'>
                    <button class='showinfo'>More information </button>
        <div class='result'>
        </div>

";

编辑

所以我尝试过的,但没有奏效的是

  $(document).ready(function(){
  setTimeout(showinfo, 1000);
 }

  function showinfo(){
        site = ($(this).closest('.row').find('li:first').text());
  $('.result').load('http://localhost/database/phpwhois-4.2.2/whois.php?query='+site+'&output=nice #result  ');
  $('.result').show();
  $('.hideinfo').show();
  $('.showinfo').hide();
      });  
  });

您需要这样的东西:

$(document).ready(function(){
  // Find each row
  $('.row').each(function(){
    // Store the current row JQuery object so we only have to find this once (better performance).
    var currentRow = $(this);
    // get the first li text
    var site = currentRow.find('li:first').text();
    // Query whois and put it into result
    currentRow.find('div.result').load('http://localhost/database/phpwhois-4.2.2/whois.php?query='+site+'&output=nice);
  })
}); 

此代码未经测试
此外
您的li应随附ulol