| xmlHttp.onreadystatechange = handleReadyStateChange; xmlHttp.open("post", url, true); //传递数据的方法同样有GET和POST两种,但是当方法为POST时下面的一句话就必须写 xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xmlHttp.send(null); } function handleReadyStateChange() { if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { if (xmlHttp.responseText == 'Y') { document.mainFrm.isExist.value = 'Y'; document.getElementById("flag").style.display = "block" document.mainFrm.segment10.focus(); } else { document.mainFrm.isExist.value = 'N'; document.getElementById("flag").style.display = "none" } } else { alert(xmlHttp.status); } } } 后台代码为: boolean success = itemDAO.doVerifyItem(); //doVerifyItem为验证指定物品是否在数据库中存在的主要方法,假如该物品已存在该方法将返回TRUE PrintWriter out = res.getWriter(); if (success) { out.print("Y"); } out.flush(); out.close(); }
|
| 共2页: 上一页 [1] 2 下一页 |
评论加载中…