日期:2014-05-16  浏览次数:20658 次

Ajax异步访问数据库,进行判断

<script type="text/javascript">
??????? var xmlHttp;
??????? function creatXmlHttp(){
?????????? if(window.XMLHttpRequest){
???????????? xmlHttp = new XMLHttpRequest();
?????????? }else if(window.ActiveXObject){
???????????? xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
?????????? }
??????? }
???????
??????? function doAjax(){
????????? var memberUserName =document.getElementById("memberUserName").value;
????????? creatXmlHttp();
????????? xmlHttp.open("GET", "<%=path%>/frontwork/MemberUserAction.do?p=memberUserRegValidationActionForward&&otherAccount=" + memberUserName, true);
????????? xmlHttp.onreadystatechange = dowork;
????????? xmlHttp.setRequestHeader("If-Modified-Since","0");
????????? xmlHttp.send(null);
??????? }
???
?????? function dowork(){
????????? if (xmlHttp.readyState == 4) { // 测试状态是否请求完成
????? if (xmlHttp.status == 200) { // 如果服务端回应OK
?????? var text = xmlHttp.responseText;
?????? var spa = document.getElementById("msg");
?????? spa.innerHTML = text;//将内容放入
????? }
??? }
?????? }
??? </script>