An error always pops up when ajax returns verification. ajaxerror

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.