Send a simple case:
Front desk:
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
Background:
public class Login_do extends HttpServlet {public
void doget (HttpServletRequest request, HttpServletResponse Response)
throws Servletexception, IOException {
this.dopost (request, response);
public void DoPost (HttpServletRequest request, httpservletresponse response)
throws Servletexception, IOException {
request.setcharacterencoding ("UTF-8");
Response.setcharacterencoding ("UTF-8");
String name =request.getparameter ("name");
String Password = request.getparameter ("password");
String js = "{\" name\ ": name,\" password\ ":p Assword}";
PrintWriter out = Response.getwriter ();
Jsonobject json = new Jsonobject ();
Json.put ("name", name);
Out.print (Json.tostring ());
Response.getwriter (). Write (json.tostring ());
When you click on login:
Workaround: There are two possible ways to eject the error message:
First:URL error, the background is not directly to the value of
You can use Firefox's firebug to view: If you respond to information, this is not the problem, then there may be the second case :
Error returning data type:
In my case, the returned data was accidentally printed two times, so just delete one sentence:
Out.print (Json.tostring ());
Response.getwriter (). Write (json.tostring ());
caused an error. The information displayed in Firebug is:
The above is for you to analyze the use of Ajax to return validation when the error always pops up, I hope to solve such problems to help.