日期:2014-05-16 浏览次数:20578 次
<script type="text/javascript"> var xMLHttpRequest = null; //开始一个请求 function doWord(){ var strUrl="http://127.0.0.1:8080/dominoTest/wordTest.do?xmbh="; var strXmbh = document.formtx.strXmbh.value; if(strXmbh != "" && strXmbh != null){ doAjax(strUrl+strXmbh); }else{ window.alert("项目编号不能为空"); } } //创建Ajax function doAjax(strUrl){ createXMLHttpRequest(); xMLHttpRequest.onreadystatechange = returnFunction; xMLHttpRequest.open("GET",strUrl,true);//false为同步调用,true为异步调用 xMLHttpRequest.setRequestHeader( "connectionTimeout" , "100000" ) ; //代理运行超过100秒,则自动断开请求,释放HTTP资源 xMLHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); xMLHttpRequest.send(null); } //创建request对象 function createXMLHttpRequest(){ if(window.XMLHttpRequest){ xMLHttpRequest = new XMLHttpRequest(); }else if(window.ActiveXObject){ try{ xMLHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ window.alert(e+"创建XMLHttpRequest对象失败"); } } if(!xMLHttpRequest){ window.alert("XMLHttpRequest对象创建失败"); } } //回调函数 function returnFunction(){ if(xMLHttpRequest.readyState == 4){//描述一种"已加载"状态;此时,响应已经被完全接收 if(xMLHttpRequest.status == 200){ var httpResponse = xMLHttpRequest.responseText; if(httpResponse == "1"){ window.alert("数据库连接失败"); }else if(httpResponse == '2'){ window.alert("合同生成失败"); }else{ window.alert("合同生成成功"); } }else{ document.write("未找到您输入的地址或服务器505错误"); } } } </script>
var strUrl="/dominoTest/wordTest.do?xmbh=";