AJAX异步传输

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="do-login" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="css/base.css" rel="stylesheet" />
<script src="js/jquery-1.11.3.js"></script>
<script type="text/javascript">
$(function(){
$("#username").blur(function(){
$.get("check-username",{username:$(this).val()},function(text){
$("#usernameErr").text(text=="false"?"用户名已重复":"");
});
});
});
</script>
</head>
<body>
 <div id="page">
        <div id="header">
            <div id="menu">
                <div id="corpTitle">美食前线</div>
                <div id="fastNav">
                    <ul>
                       <li><a href="index">首页</a></li>
<li><a href="foods-list">产品展示</a></li>
<li><a href="new-list">新闻动态</a></li>
<li><a href="message">留言板</a></li>
                        <li>联系我们</li>
                    </ul>
                </div>
                <div class="clear"></div>
            </div>
            <div class="clear"></div>
        </div>
        <div id="main">
         <form action="do-register" method="post">
            <fieldset class="edit-panel">
                <legend>用户注册</legend>
                <div>
                    <label for="username" class="fieldname">用户名:</label>
                    <input type="text" name="username" id="username" value="<%=request.getParameter("username")==null?"":request.getParameter("username")%>">
                 <label style="color:red;" id="usernameErr"></label>
                </div>
                <div><label for="password" class="fieldname">密码:</label>
                    <input type="password" name="password" id="password" value="<%=request.getParameter("password")==null?"":request.getParameter("password")%>">
                </div>
                <div><label for="password" class="fieldname">密码确认:</label>
                    <input type="password" id="passwordConfirm" value="<%=request.getParameter("passwordConfirm")==null?"":request.getParameter("passwordConfirm")%>">
                </div>
                <div><label for="email" class="fieldname">Email:</label>
                    <input type="text" id="email" value="<%=request.getParameter("email")==null?"":request.getParameter("email")%>">
                </div>
                <div>
                    <label class="fieldname">&nbsp;</label>
                    <button>注册</button> 
                    <a href="login.jsp">登录</a>
                </div>
                <div style="text-align: center;color:red">
                <%=request.getAttribute("error")==null?"":request.getAttribute("error")%></div>
            </fieldset>
            </form>
        </div>
        <div id="footer">
            <p><a>首页|</a><a>关于我们|</a><a>联系我们</a></p>
            <p>@©2016 网站样板-餐饮 版权所有</p>
            <p>技术支持:广州广力 | 手机版 | 管理登录</p>
        </div>
    </div>
 
</body>
</html>
posted @ 2017-12-11 21:54  adolphs  阅读(143)  评论(0)    收藏  举报