所以我有這個問題,我有一個數據庫客戶端,它現在的方式是,當頁面加載時,它爲數據庫中的每一行生成部分包含域名的表格,以及使用PHP的相應IP地址。我有一個「附加信息」按鈕,它從php whois -API網站加載信息,該網站掃描相應的地址並返回關於該網站的所有whois信息(創建日期,到期日期等)設置一個延遲的Whois腳本
所以我想改變這個系統從一個按鈕到instantenous系統,但似乎無法做到。
我認爲問題出在頁面嘗試它得到的信息
//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();
});
});
您已經嘗試過的「實例系統」代碼在哪裏? – 2pha
基本上,我試過的東西只是取消了點擊需要點擊 $(「。showinfo」),點擊(功能() ,然後添加一個2秒的延遲加載這個功能 – matsutus
只需刪除點擊事件監聽器不會工作,因爲click處理函數中的函數依賴於'$ this'來查找最近的行,你應該循環遍歷行,我將添加一個答案。 – 2pha