码迷,mamicode.com
首页 > Web开发 > 详细

ajax提交

时间:2014-10-28 10:18:05      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   os   ar   java   for   

servlet

bubuko.com,布布扣
表单上
<td>
<a href="javascript:void(0)" onclick="deleteRecord()">
<span id="cardid"><%=map.get("cardid")%></span>删除</a></td>

jquery
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
    function deleteRecord() {
        var cardid = $(this).parent().html();
        alert(cardid);
        $.ajax({
            url : ‘cardid.do‘,
            type : "post",
            data : {
                ‘cardid‘ : cardid
            },
            dataType : ‘html‘,
            success : function(data, status) {
                $(‘#name_msg‘).html(data);
            }
        });
        window.location.reload();
    }
</script>

后台
    String cardid = request.getParameter("cardid");//HttpServletRequest request
View Code

 

struts2

bubuko.com,布布扣
前台
<%    List users = (List) request.getSession().getAttribute("users");
            for (int i = 0; i < users.size(); i++) {
%>
<td><a href="javascript:void(0)" onclick="deleteRecord(<%=((Users) users.get(i)).getId()%>)">删除</a></td>

jquery
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
    function deleteRecord(obj) {
       var userid=obj;    
       $.ajax({
            url : ‘deleteUser‘,
            type : "post",
            data : {
                ‘userid‘ : userid
            },
            dataType : ‘html‘,
            success : function(data, status) {
                $(‘#name_msg‘).html(data);
            }
        });   
        window.location.reload();    
    }
</script>

后台
HttpServletRequest request = (HttpServletRequest) ActionContext            .getContext().get(ServletActionContext.HTTP_REQUEST);
String userid = request.getParameter("userid");
View Code

 

ajax提交

标签:style   blog   http   io   color   os   ar   java   for   

原文地址:http://www.cnblogs.com/manusas/p/4056102.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!