In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you how to log in in the local refresh application of Ajax. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Don't say a word, just give it to the code. I believe all you need is code rather than a pile of nonsense.
1.java Code:
The code is as follows:
Package tt
Import java.io.IOException
Import java.io.PrintWriter
Import javax.servlet.ServletException
Import javax.servlet.http.HttpServlet
Import javax.servlet.http.HttpServletRequest
Import javax.servlet.http.HttpServletResponse
Public class TestA extends HttpServlet {
Private static final long serialVersionUID =-7999241892841130740L
Protected void doGet (HttpServletRequest request
HttpServletResponse response) throws ServletException, IOException {
Request.setCharacterEncoding ("utf-8")
String name = request.getParameter ("name")
Response.setContentType ("text/xml; charset=utf-8")
Response.setHeader ("Cache-Control", "no-cache")
PrintWriter out = response.getWriter ()
Out.println ("")
If (name.equals ("yangjinde")) {
Out.println ("+" Sorry, the name 'yangjinde' is already registered "+")
} else {
Out.println ("+" can register with "+")
}
Out.println ("")
Out.close ()
}
}
2.jsp Code:
The copy code is as follows:
My JSP 'index.jsp' starting page
/ / set a variable
Var XMLHttpReq=false
/ / create a XMLHttpRequest object
Function createXMLHttpRequest () {
If (window.XMLHttpRequest) {/ / Mozilla
XMLHttpReq=new XMLHttpRequest ()
}
Else if (window.ActiveXObject) {
Try {
XMLHttpReq=new ActiveXObject ("Msxml2.XMLHTTP")
} catch (e) {
Try {
XMLHttpReq=new ActiveXObject ("Microsoft.XMLHTTP")
} catch (e) {}
}
}
}
/ / send request function
Function send (url) {
CreateXMLHttpRequest ()
XMLHttpReq.open ("GET", url,true)
XMLHttpReq.onreadystatechange=proce; / / specify the function of the response
XMLHttpReq.send (null); / / send request
}
Function proce () {
If (XMLHttpReq.readyState==4) {/ / object status
If (XMLHttpReq.status==200) {/ / the information has been returned successfully. Start processing the information.
Var res=XMLHttpReq.responseXML.getElementsByTagName ("content") [0] .firstChild.data
Window.alert (res)
Document.getElementById ("data") [xss_clean] = res
Document.getElementById ("name") .value = res
} else {
Window.alert ("Sorry, the requested page has an exception")
}
}
}
/ / Authentication
Function check () {
Var name=document.getElementById ("name"). Value
If (name== "") {
Alert ("Please enter content")
Return false
}
Else {
Send ('login?name='+name)
}
}
Name:
I will change later!
3.xml profile Code:
The code is as follows:
Login
Tt.TestA
Login
/ login
Index.jsp
The above content is how to simply login in the Ajax local refresh application. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.