(ASP)怎样实现隐藏层显示时才读取对应的数据?

来源:百度知道 编辑:UC知道 时间:2024/05/29 07:24:02
我的ASP网页,其中有一个隐藏层,里面是从数据库读取过来的一系列数据,我想实现就是当隐藏层被激活时,才去读取对应的数据,这样的效果怎样实现呢。

给你一个简单的例子吧!
当你点击显示那个隐藏层的时候,就调用reload()这个函数,

<script type="text/javascript">
<!--
function createxmlhttp()
{
//create xmlhttp object
xmlhttpobj = false;
try{
xmlhttpobj = new XMLHttpRequest;
}catch(e){
try{
xmlhttpobj=new ActiveXObject("MSXML2.XMLHTTP");
}catch(e2){
try{
xmlhttpobj=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e3){
xmlhttpobj = false;
}
}
}
return xmlhttpobj;

}

function reload(){
var xmlobj;
xmlobj=createxmlhttp();
xmlobj.open("get","search.asp?typeid=1",true);//这里要为那个层的内容做一个ASP页面.,如果有值传递,也可以加在后面.
xmlobj.onreadystatechange=function(){
if (xmlobj.readyState==4){
if (xmlobj.status==200){

document.getElementById("info").innerHTML=xmlobj.responseText;//加载内容.这里的info是我随便取的