var http_request=false;
  function send_request(url){//初始化，指定处理函数，发送请求的函数
    http_request=false;
	//开始初始化XMLHttpRequest对象
	if(window.XMLHttpRequest){//Mozilla浏览器
	 http_request=new XMLHttpRequest();
	 if(http_request.overrideMimeType){//设置MIME类别
	   http_request.overrideMimeType("text/xml");
	 }
	}
	else if(window.ActiveXObject){//IE浏览器
	 try{
	  http_request=new ActiveXObject("Msxml2.XMLHttp");
	 }catch(e){
	  try{
	  http_request=new ActiveXobject("Microsoft.XMLHttp");
	  }catch(e){}
	 }
    }
	if(!http_request){//异常，创建对象实例失败
	 window.alert("创建XMLHttp对象失败！");
	 return false;
	}
	http_request.onreadystatechange=processrequest;
	//确定发送请求方式，URL，及是否同步执行下段代码
    http_request.open("GET",url,true);
	http_request.send(null);
  }
  //处理返回信息的函数
  function processrequest(){
   if(http_request.readyState==4){//判断对象状态
     if(http_request.status==200){//信息已成功返回，开始处理信息
	  document.getElementById(reobj).innerHTML=http_request.responseText;
	 }
	 else{//页面不正常
	  alert("您所请求的页面不正常！");
	 }
   }
  }

 function dopage(obj,url){
   document.getElementById(obj).innerHTML="正在读取数据...";
   send_request(url);
   reobj=obj;
   }
function getNews(newsID)
{
　//如果没有把参数newsID传进来
　if (typeof(newsID) == 'undefined')
　{
　　return false;
　}
　//需要进行Ajax的URL地址

　var url = "/show.php?id="+ newsID;

　//获取新闻显示层的位置
　var show = document.getElementById("show_news");

　//实例化Ajax对象
　var ajax = InitAjax();

　//使用Get方式进行请求
　ajax.open("GET", url, true);

　//获取执行状态
　ajax.onreadystatechange = function() { 
　　//如果执行是状态正常，那么就把返回的内容赋值给上面指定的层
　　if (ajax.readyState == 4 && ajax.status == 200) { 
　　　show.innerHTML = ajax.responseText; 
　　} 
　}
　//发送空
　ajax.send(null); 
} 

function saveUserInfo()
{
　//获取接受返回信息层
　var msg = document.getElementById("msg");

　//获取表单对象和用户信息值
　var f = document.user_info;
　var userName = f.user_name.value;
　var userAge = f.user_age.value;
　var userSex = f.user_sex.value;

　//接收表单的URL地址
　var url = "/save_info.php";

　//需要POST的值，把每个变量都通过&来联接
　var postStr = "user_name="+ userName +"&user_age="+ userAge +"&user_sex="+ userSex;

　//实例化Ajax
　var ajax = InitAjax();
　
　//通过Post方式打开连接
　ajax.open("POST", url, true);

　//定义传输的文件HTTP头信息
　ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

　//发送POST数据
　ajax.send(postStr);

　//获取执行状态
　ajax.onreadystatechange = function() { 
　　//如果执行状态成功，那么就把返回信息写到指定的层里
　　if (ajax.readyState == 4 && ajax.status == 200) { 
　　　msg.innerHTML = ajax.responseText; 
　　} 
　} 
}

