日期:2014-05-16 浏览次数:20858 次
Ajax在项目中简单应用实例:
var request = false; var flag = true; //创建XMLHttpRequst对象的一个实例 function createRequest() { if(window.XMLHttpRequest) { request = new XMLHttpRequest(); } else if(window.ActiveXObject) { request = new ActiveXObject("Msxml2.XMLHTTP"); } if (!request){ alert("Error initializing XMLHttpRequest!"); } } function getIsNotRepeat() { createRequest(); var exportDate = document.frmExportSubjectBalance.strExportSubjectBalanceDate.value; var url = "<%=strContext%>/FindExistSubjectBalance.jsp?exportDate=" + exportDate; request.open("GET", url, false); request.onreadystatechange = updatePage; request.send(null); } function updatePage() { if (request.readyState == 4) { if (request.status == 200) { var respText = request.responseText; /* 返回1,科目余额已存在 */ if( respText == 1 ){ if(confirm('科目余额已存在,是否重新导入?')){ flag = true; }else{ flag = false; } }else{ flag = true; } } } }
?