//公用ajax
 function createXMLHttpRequest()
  {
    if (window.ActiveXObject) 
     {
       if(navigator.userAgent.toLowerCase().indexOf('msie 5')!=-1)
        {
          xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
     else
      {
         xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
       }
      } 
     else if (window.XMLHttpRequest) 
      {
        xmlHttp = new XMLHttpRequest();
       }
     else
      {
       alert("Create XMLHttpRequest error");
       }
   }
//method提交方式:post get 
//url
//responsefunction 回调函数
function ajax(method,url,responsefunction)
   {
   createXMLHttpRequest();
  if(method==""||method==null)
  {
  method="post"
  }
  else if(method!="get"||method!="post")
  {
  method="post"
  }
  
   xmlHttp.open(method, url, true);
   xmlHttp.onreadystatechange = responsefunction;
   xmlHttp.send(null);
   }
//检查函数 无异常才会调用回调函数  
function check(responsefunction)
{
 if(xmlHttp.readyState==4)
	 {
		 if(xmlHttp.status==200){
		responsefunction();
		 }
 	 }
}
/** 
使用例子
 function testajax()
 {
   var url = "http://127.0.0.1:8080/Struts_Spring_ibatis/common/common_testajax.action";
  ajax("post",url,function(response){
  var i=1;
	check(function(response){
	//验证返回信息
		var returnStr=xmlHttp.responseText;
		alert(xmlHttp.responseText);
		if(returnStr=="1"){ 
			alert(i+1);
		}
	 });	
	}); 
 }
*/