Home > Web Front-end > JS Tutorial > jquery study notes Use jquery to achieve refresh-free login_jquery

jquery study notes Use jquery to achieve refresh-free login_jquery

WBOY
Release: 2016-05-16 18:03:45
Original
1544 people have browsed it

Okay, that’s it for the chatter. Now let’s see how to use jquery to achieve refresh-free login.
First create the html part

Copy the code The code is as follows:



Username:







Password:







Verification code:



Click to change the verification code










The functions included here are: login Verify, click Change Verification Code. There is nothing to say about this.
The following is the jquery part
Copy the code The code is as follows:

-----------Don’t forget to quote this link, otherwise jquery will not work


This is the approximate core code. When the user clicks the login button, the login event is triggered, and jquery is used to log in to Login.ashx When making a request, in Login.ashx, it just verifies whether the username and password match and whether the verification code is correct. Login.ashx is written in C# language. If you are learning another language, just change the address to another one.
img.ashx is a program that generates verification codes. Every time you click on an image, img.ashx will be revisited, so the image is changed. When the image is generated, a session will be generated to store the verification code. In Login.ashx, Just determine whether the value entered by the user and the value of the session are the same. Here I only show the main source code.
Copy code The code is as follows:

context.Response.ContentType = "text/plain";
string username = context.Request.Form["username"];
string password = context.Request.Form["password"];
string cord = context.Request.Form["cord"] ;
if (context.Session["cord"] != null)
{
if (context.Session["cord"].ToString() == cord)
{
if (username == "admin" && password == "admin")
{
context.Response.Write("Login successful!");
}
else
{
context.Response.Write("Login failed! Username and password are wrong!");
}
}
else
{
context.Response.Write("Verification code is wrong!" );
}
}

This is the code to determine login.
Okay, the above is the core code, I hope you can give me some advice. I also hope my notes are useful to you
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template