An error always pops up when ajax returns verification. ajaxerror
Send a simple case:
Front-end:
<% @ 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\":password}"; PrintWriter out = response.getWriter(); JSONObject json = new JSONObject(); json.put("name",name); out.print(json.toString()); response.getWriter().write(json.toString()); } }
Click to log on:
Solution:There are two possible error messages:
First:Url error. The value cannot be obtained directly in the background.
You can use firebug of Firefox to view the problem: If the response information is returned, it is not the problem.Case 2:
Returned data type error:
In my example, the returned data is accidentally printed twice. just delete the two sentences:
out.print(json.toString()); response.getWriter().write(json.toString());
An error occurred. The information displayed in firebug is:
The above is the reason why an error always pops up when ajax is returned for verification. I hope it will help you solve this problem.
Articles you may be interested in:
- Asp + Ajax simple client login verification
- Check whether Ajax User Name authentication exists
- Ajax Form Verification implementation code
- Jquery ajax login verification implementation code
- Use Jquery Ajax in Asp.net to detect User Registration (verify whether the user name is saved)
- Implementation Code for verifying the existence of user names based on Ajax implemented by jQuery
- Ajax real-time verification of user name/mailbox and other existing code Packaging
- PHP + Ajax asynchronous communication Implements user name email verification (two methods)
- Ajax verification issues in the formvalidator verification plug-in