﻿var xmlHttp;
function createXMLHttpRequest()
{
    try{
        xmlHttp=new XMLHttpRequest();
    }
    catch(e){
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

}
function startRequest(pageIndex,ajaxPageStyle)
{
    document.getElementById("PagerList").innerHTML="<span style='margin:100px 0px 100px 300px;display:block;color:blue;'><img src='/Image/loading.gif' alt='数据载入中...' title='数据载入中...' /> 数据载入中...</span>";
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET","/Ashx/DataPager.ashx?ID="+pageIndex+"&Type="+ajaxPageStyle+"&"+(new Date()).getTime(),true);
    xmlHttp.send(null);
}
function handleStateChange()
{
    if(xmlHttp.readyState==4 && xmlHttp.status==200)
    {
        document.getElementById("PagerList").innerHTML=xmlHttp.responseText;
    }
}

function SetPageIndex(pageindex){
    startRequest(pageindex,document.getElementById("AjaxPageStyle").innerHTML);
}


//删除评论，文章
function DelData(id,cla){
    var delxmlHttp;
    try{
        delxmlHttp=new XMLHttpRequest();
    }
    catch(e){
        delxmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    delxmlHttp.onreadystatechange = function(){
        if(delxmlHttp.readyState==4 && delxmlHttp.status==200)
        {
            var result=delxmlHttp.responseText;
            if(result=="OK"){
                SetPageIndex('1');
                alert("删除成功！")
            }
            else{
                alert(result)
            }
        }
    };
    delxmlHttp.open("post","/Ashx/Del.ashx?"+Math.random(),true);
    delxmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    var param="ID="+id+"&Cla="+cla;
    delxmlHttp.send(param);
}