代码如下(貌似不会进XMLHttpReq.status == 200这个判断里,但没抱任何错):
servlet:
response.getWriter().print(task_id);
页面:
function hh(){
createXMLHttpRequest();
var url="<%=request.getContextPath()%>/apply";
var pemer = "action=save&uid="+uid;
XMLHttpReq.open("POST",url, true);
XMLHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
XMLHttpReq.onreadystatechange = processListResponse1;
XMLHttpReq.send(pemer);
window.location.href="<%=request.getContextPath()%>/revtaskM.do?action=toGo";
}
function processListResponse1() {
alert("processListResponse1");
if (XMLHttpReq.readyState == 4) {
if (XMLHttpReq.status == 200) {
task=XMLHttpReq.responseText;
alert(task);
}
}
}