Ajax登录
前端之家收集整理的这篇文章主要介绍了
Ajax登录,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!
DOCTYPE
html
PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
Meta
http
-
equiv
=
"Content-Type"
content
=
"text/html; charset=utf-8"
/>
<
title
>
欢迎登录后台管理系统
</
title
>
<
link
href
=
"css/style.css"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
script
language
=
"JavaScript"
src
=
"js/jquery.js"
></
script
>
<
"js/cloud.js"
"text/javascript"
></
script
>
<
"javascript"
>
$
(
function
(){
$
(
'
.
loginBox
'
).
css
({
'
position
':'
absolute
','
left
'
:(
window
).
width
()-
692
)/
2
});
resize
(
function
(){
2
});
})
});
</
script
>
</
head
>
<
body
style
=
"background-color:#df7611; background-image:url(images/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;"
>
<
div
id
=
"mainBody"
>
<
"cloud1"
class
="
cloud
"></div>
<div id="
cloud2
" class="
cloud
"></div>
</div>
<div class="
logintop
">
<span>欢迎
登录后台管理界面平台</span>
<ul>
<li><a href="
#
">回首页</a></li>
<li><a href="
">帮助</a></li>
<li><a href="
">关于</a></li>
</ul>
</div>
<div class="
loginbody
">
<span class="
systemlogo
"></span>
<ul>
<li><input name="" type="
text
loginuser
" value="
admin
" onclick="
JavaScript:
this
.
value
=
''
"/></li>
@H_750_403@
<li><input name="" type="
loginpwd
" value="
密码
"/></li>
<li><input name="" type="
button
loginbtn
登录
javascript:
window
.
location
=
main
.
html
'
" /><label><input name="" type="
checkBox
" value="" checked="
checked
" />记住密码</label><label><a href="
">忘记密码?</a></label></li>
</ul>
</div>
</div>
<div class="
loginbm
">版权所有 2014 <a href="
http:
//www.uimaker.com">uimaker.com</a> 仅供学习交流,勿用于任何商业用途</div>
</
body
>
</
html
>
****************************************************************************************************************
var
xmlhttp
;
function
getload
()
{
document
.
getElementById
(
"loginname"
).
focus
();
@H_
404_577@
}
getIE
()
{
if
(
XMLHttpRequest
)
{
xmlhttp
=
new
XMLHttpRequest
();
}
else
{
ActiveObject
(
"Microsoft.XMLHTTP"
);
}
}
loginname
(
obj
)
{
getIE
();
name
=
obj
.
value
;
name
.
length
==
0
)
{
"nameflag"
).
innerHTML
=
"<font color=red></font>"
;
"Loginbtn"
).
style
.
visibility
=
"hidden"
;
}
else
{
url
=
"${pageContext.request.contextPath}/emp_myname.action?name="
+
name
;
myurl
=
encodeURI
(
url
);
xmlhttp
.
open
(
"post"
,
myurl
,
true
);
send
();
onreadystatechange
=
getBack
;
}
}
getBack
()
{
readyState
==
4
&&
status
==
200
)
{
responseText
==
1
)
{
""
;
"visible"
;
}
else
{
"<font color=red></font>"
;
"hidden"
;
}
}
}
login
(){
getIE
();
name
=
value
;
psw
=
"loginpsw"
).
value
;
0
){
"<font color=red></font>"
;
}
else
psw
.
0
){
alert
(
"瀵嗙爜涓嶈兘涓虹┖"
);
}
else
{
url
=
encodeURI
(
"${pageContext.request.contextPath}/emp_getlogin.action?name="
+
name
+
"&"
+
"psw="
+
psw
);
url
,
true
);
send
();
onreadystatechange
=
loginback
;
}
}
//回滚
loginback
(){
if
(
readyState
==
4
&&
status
==
200
)
{
1
){
location
.
href
=
"./main.jsp"
;
}
else
{
"xx"
).
innerHTML
=
"<font color=red></font>"
;
return
false
;
}
}
}
*********************************************************************************************
Action
public
String
myname
()
{
int
result
=
0
;
try
{
String
myname
=
String
(
getBytes
(
"ISO8859_1"
),
"utf-8"
);
int
t
=
empService
.
getLoginName
(
myname
);
HttpServletResponse
response
=
ServletActionContext
.
getResponse
();
response
.
setContentType
(
"text/html;charset=UTF-8"
);
PrintWriter
out
=
getWriter
();
t
>
0
)
{
1
;
}
else
{
0
;
}
out
.
println
(
result
);
flush
();
close
();
}
catch
(
Exception
e
)
@H_480_1
404@
{