ajax+asp无限级分类树型结构的代码

2019-09-14 07:20:28于丽

document.getElementById("s"+oldid).style.backgroundColor="white";
document.getElementById("s"+currentID).style.backgroundColor="#C0C0E9";
}
//创建XMLHttpRequest对象
function CreateXMLHttpRequest()
{
    if (window.ActiveXObject)
    {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
        xmlHttp = new XMLHttpRequest();
    }
}
//Ajax处理函数
//id,层id
//rid,数据在表中的id
function ShowChild(cid,id)
{
    CreateXMLHttpRequest();
    if(xmlHttp)
    {
        xmlHttp.open('POST','child.asp',true);
        xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        var SendData = 'id='+id;
        xmlHttp.send(SendData);
        xmlHttp.onreadystatechange=function()
        {
           if(xmlHttp.readyState==4)
           {
             if(xmlHttp.status==200)
             {
                GetId(cid).innerHTML = xmlHttp.responseText;
             }
             else
             {
                GetId(cid).innerHTML='出错:'+xmlHttp.statusText;
             }
           }
           else
           {
                GetId(cid).innerHTML="正在提交数据...";
            }
          }

     }
     else
     {
         GetId(cid).innerHTML='抱歉,您的浏览器不支持XMLHttpRequest,请使用IE6以上版本!';