function CreateHTTPObject()
{
    var xmlhttp;    
    try
    {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
        try
        {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {
            xmlhttp = false;
        }
    }    
    if (!xmlhttp && typeof XMLHttpRequest!='undefined')
    {
        try
        {
            xmlhttp = new XMLHttpRequest();
        }
        catch (e)
        {
            xmlhttp=false;
        }
    }    
    if (!xmlhttp && window.createRequest)
    {
        try
        {
            xmlhttp = window.createRequest();
        }
        catch (e)
        {
            xmlhttp=false;
        }
    }    
    return xmlhttp;
}
//使用全局变量 xmlhttp
function OnReadyStateChng(xmlhttp,div_id)
{
    if (xmlhttp.readyState != 4 && xmlhttp.readyState!=1)//xmlhttp.readyState!=1去掉此句老提示找不到div的ID,不知道为什么
    {
  document.getElementById(div_id).innerHTML = "<img src=000000.gif>"; //处理完毕
    }
    else if (xmlhttp.readyState == 4)
    {
        document.getElementById(div_id).innerHTML = xmlhttp.responseText; //处理完毕
    }    
}
function ajax_post(div_id,url)
{
var xmlhttp = CreateHTTPObject();
if (xmlhttp)
{  
  xmlhttp.open("POST",url, true);
  xmlhttp.onreadystatechange = function(){OnReadyStateChng(xmlhttp,div_id);};
  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); //这一句是用post方法发送的时候必须写的
  xmlhttp.send();
}
}
function ajax_get(div_id,url)
{
var xmlhttp = CreateHTTPObject();
if (xmlhttp)
{
  xmlhttp.open("GET", url, true);
  xmlhttp.onreadystatechange = function(){OnReadyStateChng(xmlhttp,div_id);};
  xmlhttp.send(null);
}
}

