The concrete realization _jquery of the jquery user Famous school examination

Source: Internet
Author: User

This example for you to share the jquery user Famous school inspection function, share for everyone to reference, the specific content as follows

$ (document). Ready (function () {}): Defines the method that needs to be executed when a page mount completes.
$ () Gets the node specified by the page, and the parameter is a selector for some kind of CSS. Returns a JQuery object on which to execute the jquery method.
The Val () method can get the value of the node
HTML () to set HTML content in a node
Click () corresponding mouse click event
KeyUp () corresponding keyboard bounce Event
$.get () can interact with the server for Get mode, and the registered callback method is invoked when the data comes back, and this method receives a plain text parameter representing the server-side returned data
AddClass () Removeclass () Adds or deletes a class to a node
solve the Chinese garbled problem: sent to the server side of the data in JS do two times encodeURI, and then in the server-side code in the UTF-8 way to do a urldecode

Main code:

$.get ("http://localhost:8080/JQueryStudy/UserVerify?userName=" + encodeURI (encodeURI (userName)), NULL,
          Function (response) {
            $ ("#result"). HTML (response);
          }
        )

The Servlet processed

* * To change this template, choose Tools |
 Templates * and open the template in the editor.

* * Package com.linying;
Import java.io.IOException;
Import Java.io.PrintWriter;
Import Java.net.URLDecoder;
Import javax.servlet.ServletException;
Import Javax.servlet.http.HttpServlet;
Import Javax.servlet.http.HttpServletRequest;

Import Javax.servlet.http.HttpServletResponse; /** * User Name Validation servlet * @author ying-er * @time 2010-4-25 PM 08:02:08 * @version 1.0/public class Userverify extends Ht Tpservlet {/** * processes requests for both HTTP <code>GET</code> and <code>POST</code>
  Methods. * @param request servlet Request * @param response servlet response */protected void ProcessRequest (httpservletrequ EST request, httpservletresponse response) throws Servletexception, IOException {response.setcontenttype ("text/html
    ; Charset=utf-8 ");
    PrintWriter out = Response.getwriter (); try {String param = request.getparameter ("UsernaMe ");
      if (param = null | | param.length () = 0) {out.println ("User name cannot be empty");
        else {String userName = Urldecoder.decode (param, "UTF-8");
        System.out.println (UserName);
        if (Username.equals ("Ying-er")) {out.println ("user name [+ userName +"] already exists, please use another username to register ");
        else {out.println ("can use user name [" + UserName + "] register");
    }}} finally {Out.close (); }//<editor-fold defaultstate= "collapsed" desc= "HttpServlet" >/** * Handles the HTTP &LT;CODE&GT;GET&L
  T;/code> method. * @param request servlet Request * @param response servlet response */protected void doget (HttpServletRequest reque
  St, httpservletresponse response) throws Servletexception, IOException {processrequest (request, response);
  }/** * Handles HTTP <code>POST</code> method. * @param request servlet Request * @param response servlet response */protected void DoPost (HttpServletRequest request, HttpServletResponse response) throws Servletexception, IOException {processrequest (Request, Respon
  SE);
  }/** * Returns A short description of the servlet.
  */Public String Getservletinfo () {return ' short description ';
 }//</editor-fold>}

The above is the entire content of this article, I hope to help you learn.

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.