首页 > 代码库 > ajax提交
ajax提交
servlet
表单上<td><a href="javascript:void(0)" onclick="deleteRecord()"><span id="cardid"><%=map.get("cardid")%></span>删除</a></td>jquery<script type="text/javascript" src="http://www.mamicode.com/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
struts2
前台<% 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="http://www.mamicode.com/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");
ajax提交
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。