如何整合jquery和struts
我写了一段代码
JSP:
<html>
<head>
<script src="js/jquery-1.2.3.js" type="text/javascript"></script>
<script src="js/custom.js" type="text/javascript"></script>
</head>
<body>
<input type="text" id="in"/>
<input type="button" value='submit'onclick="output();"/>
<div id='out' ></div>
</body>
</html>
action:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
// TODO Auto-generated method stub
response.setContentType("text/xml; charset=gbk");
response.getWriter().print("<font color=blue>"+request.getParameter("in")+"<font>");
return null;
}
custom.js
function output(){
$.post("out.do?in="+$('#in').val(),null,function(msg){$('#out').html(msg);});
}
希望页面输入框的内容提交后直接谈过AJAX输出到页面上。现在debug能进入action,但是页面没有效果,使用$ajax也是这样