JQuery + Ajax to achieve no refreshing _ jquery

Source: Internet
Author: User
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:

  

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.