﻿// Ajax共用文件

var xmlHttp;
var methord;
function createXMLHttpRequest(url)
{
    if(window.ActiveXObject)
    {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        methord="post";
    }
    else if(window.XMLHttpRequest)
    {
        xmlHttp = new XMLHttpRequest();
        methord="get";
    }
    xmlHttp.onreadystatechange=XmlOnReadyStateChange;
    xmlHttp.open(methord,url,false);
    xmlHttp.send(null);
    return XmlOnReadyStateChange();
}
function createTextHttpRequest(url)
{
    if(window.ActiveXObject)
    {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        methord="post";
    }
    else if(window.XMLHttpRequest)
    {
        xmlHttp = new XMLHttpRequest();
        methord="get";
    }
    xmlHttp.onreadystatechange=TextOnReadyStateChange;
    xmlHttp.open(methord,url,false);
    xmlHttp.send(null);
    return TextOnReadyStateChange();
}
//返回为text
function TextOnReadyStateChange()
{
    var code;
    if(xmlHttp.readyState ==4)
    {
        if(xmlHttp.status==200)
        {
            code = xmlHttp.responseText;
        }
    }
    return code;
}
//返回xml数据
function XmlOnReadyStateChange()
{
    var code;
    if(xmlHttp.readyState ==4)
    {
        if(xmlHttp.status==200)
        {
            code = xmlHttp.responseXml;
        }
    }
    return code;
}