所以我有这个问题,我有一个数据库客户端,现在的方式是,当页面加载时,它会为包含域名的数据库表中的每一行生成部分,并且相应的PHP的IP地址。
最重要的是,我有一个"附加信息" -button,从php whois -API站点加载信息,扫描相应的地址并返回有关该站点的所有信息(创建日期,到期日期等)
所以我想将这个系统从一个按钮更改为一个系统,但似乎无法实现。
我认为问题在于页面在获取信息之前尝试加载所有脚本
//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>
&#34 ;;
修改
所以我尝试的东西,没有工作是
的内容 $(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();
});
});
答案 0 :(得分:2)
你需要这样的东西:
$(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
括起来。