急!!jsp+servlert+prototype1.5+ajax返回值问题
我需要的效果是,当servlert处理完以后,test.jsp页面中ID为showit的DIV显示输入的结果(这只是一个测试程序,所以流程简单,请不要说可以就用JS在客户端实现)。但是我每次servlert处理完了以后,页面上还是显示数据处理,也就是说AJAX的状态没有一直没有到200.请问如何解决,很急,谢谢各位大大了!
自己也指导servlert处理数据是无返回值的,但是就是不懂,AJAX中XMLHTTPRequest这个对象是怎么处理这样的情况的!?
问题补充:页面代码如下:
test.jsp:
<script language= "JavaScript " type= "text/JavaScript " src= "myjs/prototype.js "> </script>
<script language= "JavaScript " type= "text/JavaScript "> <!--
//此处是我的表单处理函数本函数无错,所以不贴出
function setPostBody(_form){
。。。。}
//此处是AJAX提交函数
function posttest(){
var url = 'Test ';//servlertname
var ajax = new Ajax.Request(url,{
method: 'post ',
contentType: 'application/x-www-form-urlencoded ',
encoding: 'UTF-8 ',
postBody: setPostBody($( 'mytest ')),
onLoading: function(){
$( "showit ").innerHTML = "正在处理数据... ";
},
onSuccess: function(){
$( "showit ").innerHTML= request.responseText;
}
});
}
--> </script>
<form name= "mytest " onSubmit= "posttest();return false; ">
<div>
<input type= "text " id= "tname " name= "tname "/>
<input type= "text " id= "tother " name= "tother "/>
<input type= "submit " id= "but " value= "submit "/>
</div>
</form>
<div id = "showit "> </div>
servlert代码如下:
package dreamtime.dreamnews;
import
java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import
java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;
import
javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class for Servlet: TestServlet
*
* @web.servlet
* name= "TestServlet "
* display-name= "TestServlet "
* description= "test "
*
* @web.servlet-mapping
* url-pattern= "/TestServlet "
*
* @web.servlet-init-param
* name= "getValue "
* value= "1 "
* description= "test "
*
*