2016-05-16 264 views
1

所以我有这个问题,我有一个数据库客户端,它现在的方式是,当页面加载时,它为数据库中的每一行生成部分包含域名的表格,以及使用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(); 

     }); 
    }); 
+0

您已经尝试过的“实例系统”代码在哪里? – 2pha

+0

基本上,我试过的东西只是取消了点击需要点击 $(“。showinfo”),点击(功能() ,然后添加一个2秒的延迟加载这个功能 – matsutus

+0

只需删除点击事件监听器不会工作,因为click处理函数中的函数依赖于'$ this'来查找最近的行,你应该循环遍历行,我将添加一个答案。 – 2pha

回答

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 s应包含ulol

+0

This Works!It load the information on page load!Thank you very很多人!:) 此外,感谢评论你的过程 – matsutus