jsp&&ajax responseText为空

2025-05-13 20:54:29
推荐回答(1个)
回答1:

你先调用的processRequest然后再发送请求responseText咋会有内容呢?
http_request.onreadystatechange=processRequest;
//确定发送请求的方式和URL以及是否同步执行
http_request.open("GET",url,true);
http_request.send(null);

这几句的顺序调整一下,先发送请求在调用processRequest
http_request.open("GET",url,true);
http_request.send(null);
http_request.onreadystatechange=processRequest;

doMessage.jsp中设置回复的头信息
response.setContentType("text/xml; charset=UTF-8");
response.setHeader("Cache-Control","no-cache");

如果这样都还不行的话你就一步一个alert看程序执行到哪里也能检查出问题啊,靠你自己咯....