通用ajax

            var xmlHttpReq;      
            //创建XMLHTTP对象      
            function createXMLHttpRequest(){      
                if(window.ActiveXObject){      
                    xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");      
                }else{      
                    xmlHttpReq = new XMLHttpRequest();      
                }      
            } 
 function getWZ(){
			var zhth = document.getElementById("wzbm")
               if(zhth != ""){			
                createXMLHttpRequest();      
                var wzbm =document.getElementById("wzbm").value;          
                //处理检查的地址      
                var url="getWZ.jsp?wzbm="+wzbm;      
                xmlHttpReq.open("GET",url,true);      
                xmlHttpReq.onreadystatechange = showResultWZ;
                xmlHttpReq.send();      
				}
            }      
                  
            function showResultWZ(){      
                if(xmlHttpReq.readyState == 4){      
                    if(xmlHttpReq.status == 200){      
                        var result = xmlHttpReq.responseText.replace(/^\s*|\s*$/g,"");//将响应信息作为字符串返回   		
                        var ss = result.replace(reg, ""); 
						var reg = /\s/g; 
						//alert("返回字符串:"+ss);
						 var   array=new   Array(); 

						arr=ss.split(",");
                        ///alert(arr);
						//wzmc biem ggxh cl jldw dz zz lsth jh
						//    String sql="select m.DH q0,m.MC q1,m.BIEM q2,m.GGXH q3,m.CL q4,m.JLDW q5,m.DZ q5,ZZ q6,m.LSTH q7,m.JH q8,m.SL q9  from EAM_ACC_MCODE m where m.DH='"+wzbm+"'";
						document.getElementById("wzmc").value=arr[1];
						document.getElementById("biem").value=arr[2];
						document.getElementById("ggxh").value=arr[3];
						document.getElementById("cl").value=arr[4];
						document.getElementById("jldw").value=arr[5];
						document.getElementById("dz").value=arr[6];
						document.getElementById("zz").value=arr[7];
						document.getElementById("lsth").value=arr[8];
						document.getElementById("jh").value=arr[9];
                        //var checkResult = document.getElementById("yhmc").value=ss;   
                    }      
                }      
            }

 

你可能感兴趣的:(Ajax)