This article mainly introduces jQuery + Ajax to implement brushless new operations, and shares examples of implementing "brushless New login" using Ashx + jQueryAjax. If you are interested, please refer
Ajax operations using jQuery
It is a little difficult to directly use Ajax code to achieve the refreshing effect of Ajax pages, so we want to implement it using jQuery. JQuery encapsulates the core object XMLHTTPRequest of Ajax. So it is very convenient to use.
First, create the server code. Here, use Servlet to process data on the server. The Code is as follows:
Protected void doPost (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {// set the encoding format resp. setContentType ("text/html; charset = UTF-8"); // create the output object PrintWriter out = resp. getWriter (); // obtain the request parameter String name = req. getParameter ("uname"); // determines if (name = null | name. length () = 0) {out. println ("the user name cannot be blank! ");} Else {// determine if (name. equals (" cheng ") {out. println (" username ["+ name +"] already exists! Please use another user name! ");} Else {out. println (" username ["+ name +"] does not exist! You can register! ");}}}
Then, to create a JSP page and use jQuery, you must introduce the jQuery library, that is, a Javascript file, and introduce a custom Javascript file, as shown below: