延迟设置 Whois 脚本
Setting up an Whois -script on a delay
所以我遇到了这个问题,我有一个数据库客户端,现在的情况是,当页面加载时,它会为数据库 table 中的每一行生成部分,其中包含域名,以及对应的 IP 地址 PHP。
最重要的是,我有一个 "additional information" -按钮,它从 php whois -API 站点加载信息,该站点扫描相应的地址和 returns 所有 whois - 关于该站点的信息(创建日期、到期日期等)
所以我想把这个系统从一个按钮变成一个瞬时系统,但似乎做不到。
我认为问题在于页面在获取信息之前试图加载所有脚本
//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
应该用 ul
或 ol
括起来。
所以我遇到了这个问题,我有一个数据库客户端,现在的情况是,当页面加载时,它会为数据库 table 中的每一行生成部分,其中包含域名,以及对应的 IP 地址 PHP。
最重要的是,我有一个 "additional information" -按钮,它从 php whois -API 站点加载信息,该站点扫描相应的地址和 returns 所有 whois - 关于该站点的信息(创建日期、到期日期等)
所以我想把这个系统从一个按钮变成一个瞬时系统,但似乎做不到。
我认为问题在于页面在获取信息之前试图加载所有脚本
//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
应该用 ul
或 ol
括起来。