index.asp 页面代码
代码如下:
set cmd = conn.execute(select bigclassid,bigclassname from bigclass)
tempid=cmd(bigclassid)
%>
if not cmd.eof then
do while not cmd.eof
bigclassid= cmd(bigclassid)
bigclassname = cmd(bigclassname)
%>
cmd.movenext
loop
end if
cmd.close
set cmd = nothing
%>
set cxd = conn.execute(select * from smallclass where bigclassid= & tempid)
if not cxd.eof then
do while not cxd.eof
smallclassid= cxd(smallclassid)
smallclassname = cxd(smallclassname)%>
cxd.movenext
loop
cxd.close
set cxd = nothing
else
html = 暂无小类
response.write html
end if
%>
ajax.js 代码
代码如下:
// javascript document
function createxmlhttp()
{
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 getsubcategory(bigclassid){
if(bigclassid==0){
document.getelementbyid(subclass).innerhtml=选择二级分类;
return;
};
var xmlhttpobj = createxmlhttp();
if(xmlhttpobj){//如果创建对象xmlhttpobj成功
xmlhttpobj.onreadystatechange=handle;
xmlhttpobj.open('get',getsubcategory.asp?bigclassid=+bigclassid+&number=+math.random(),true);//get方法 加个随机数。
xmlhttpobj.send(null);
}
}
function handle(){//客户端监控函数
//if(xmlhttpobj.readystate==4){//服务器处理请求完成
if(xmlhttpobj.status==200){
//alert('ok');
var html = xmlhttpobj.responsetext;//获得返回值
document.getelementbyid(subclass).innerhtml=html;
}else{
document.getelementbyid(subclass).innerhtml=对不起,您请求的页面有问题...;
}
/
