$.get()

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <form id="form" action="#">
    <p>
        姓名:<input type="text" name="username" id="username" /></p>
    <p>
        内容:<textarea name="content" id="content" rows="2" cols="20"></textarea></p>
    <p>
        <input type="button" id="send" value="提交" /></p>
    </form>
    <div class="comment">
        已有评论:</div>
    <div id="resText">
    </div>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#send").click(function () {
                $.get("Comment.aspx", {
                    username: $("#username").val(),
                    content: $("#content").val()
                }, function (data, textStatus) {
                    var username = $(data).find("comment").attr("username");
                    var content = $(data).find("content").text();
                    var txtHtml = "<div class='comment'> <h6>" + username + ":</h6> <p class='para'>" + content + "</p> </div>";
                    $("#resText").html(txtHtml);
                });
            })
        })
    </script>
</body>
</html>

posted @ 2016-06-28 15:37  Chris_在IT道路上前行  阅读(116)  评论(0编辑  收藏  举报