Javascript 在延迟上设置Whois脚本
所以我有一个问题,我有一个数据库客户机,现在的情况是,当页面加载时,它会为数据库表中的每一行生成节,其中包含一个域名,并使用PHP为其生成相应的IP地址 除此之外,我还有一个“附加信息”按钮,它从一个php whois-API站点加载信息,该站点扫描相应的地址并返回关于该站点的所有whois信息(创建日期、过期日期等) 所以我想把这个系统从一个按钮改成一个即时系统,但似乎不能 我认为问题在于页面试图在获取信息之前加载所有脚本Javascript 在延迟上设置Whois脚本,javascript,php,jquery,html,whois,Javascript,Php,Jquery,Html,Whois,所以我有一个问题,我有一个数据库客户机,现在的情况是,当页面加载时,它会为数据库表中的每一行生成节,其中包含一个域名,并使用PHP为其生成相应的IP地址 除此之外,我还有一个“附加信息”按钮,它从一个php whois-API站点加载信息,该站点扫描相应的地址并返回关于该站点的所有whois信息(创建日期、过期日期等) 所以我想把这个系统从一个按钮改成一个即时系统,但似乎不能 我认为问题在于页面试图在获取信息之前加载所有脚本 //This is the Jquery for the button
//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(){
// 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
s应该用ul
或ol
封装 您已经为“InstanceNous系统”尝试过的代码在哪里?基本上,我尝试过的只是取消了对点击$(“.showinfo”)的需要。点击(函数()然后为加载此函数添加2秒延迟仅删除单击事件侦听器无效,因为单击处理程序中的函数依赖于$this
查找最近的行。您应该在行上循环。我将添加一个答案。这很有效!它会在页面加载时加载信息!非常感谢!:)还有,感谢您评论您的流程
$(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);
})
});