Example of implementing Ajax to verify whether the user name is available based on jQuery

亚连
Release: 2018-05-29 09:46:25
Original
1448 people have browsed it

This article mainly introduces in detail the example of implementing Ajax based on jQuery to verify whether the user name is available. It has certain reference value. Interested friends can refer to it.

The examples in this article are shared with you. jQuery ajax simple case - specific code to verify whether the user name is available, for your reference, the specific content is as follows

HTML

    Insert title here   


Copy after login

LoginServlet

public class LoadServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 解决乱码 request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); // 1.得到用户名 String username = request.getParameter("username"); // 2.判断用户名是否可以使用 if ("tom".equals(username)) { // 用户名不可以使用 response.getWriter().write("用户名被占用"); } else { // 用户名可以使用 response.getWriter().write("用户名可以使用"); } } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }
Copy after login

web.xml

  LoadServlet LoadServlet  com.zxl.servlet.LoadServlet   LoadServlet /load 
Copy after login

The above is I compiled it for everyone, I hope it will be helpful to everyone in the future.

Related articles:

Simple tutorial on using less in vue2

##vue-cli scaffolding-configuration file under bulid

#vue Sample code for developing a button component

##

The above is the detailed content of Example of implementing Ajax to verify whether the user name is available based on jQuery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!