ajax非同期リクエストpost方式

850 ワード


//       
function createXhr(){
 //               
/*  var xhr;
 var str=window.navigator.userAgent;
 if(str.indexOf('MSIE')>0){
	xhr=new ActiveXObject('Microsoft.XMLHTTP');
 }else{
	xhr=new XMLHttpRequest();
 }
return xhr;
 */
 try{
	  return new ActiveXObject('Microsoft.XMLHTTP');
  }catch(e){
   }
  try{
	  return new XMLHttpRequest();
  }catch(e){
  }
   
};
//ajax Post  
 	     var data="username=zs&&password=123456";
           var xhr=createXhr();
           xhr.onreadystatechange=function(){
        	    if(xhr.readyState==4&&xhr.status==200){
              };
           }
   		  xhr.open("post","/ajaxPost1");
   		  xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded')
   	      xhr.send(data);