问题描述
- ajax回调函数不执行 请输入长度为10-50-50的问题标
-
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%> <html> <head> <script type="text/javascript" src="js/jquery-1.7.2.js"></script> <script type="text/javascript"> function checkAccount(){ var account = $("#account").val(); $.post("SServlet",{"account":account},function(data){ alter(data); if(data=="true"){ $("#s1").val("可以使用"); }else{ $("#s1").val("不能使用"); } }); } </script> </head> <body> <input type="text" id="account" onblur="javascript:checkAccount()" name="account"/><span id = "s1"></span> </body> </html> //***************************************上面的是jsp import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.JspWriter; import com.sun.xml.internal.bind.CycleRecoverable.Context; import com.sxt.dao.UserinfoDAO; public class SServlet extends HttpServlet { //如果要把中文数过去 加这句response.setContentType("text/html;charset=gbk"); public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("****"); request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=gbk"); String name = request.getParameter("account"); System.out.println(name); UserinfoDAO udao = new UserinfoDAO(); boolean k = udao.check(name); System.out.println(k); PrintWriter out = response.getWriter(); //PrintWriter out.print(k); } } //********************************上面的servlet执行正确 **** 大灯 true //********************* 但是回调函数拿不到值 help me
解决方案
http://ask.csdn.net/questions/209491
时间: 2024-09-10 00:21:12