终于向Ajax迈出了第一步
前台代码:
    <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        function deleteUser(id){
            $.post("UserList.ashx",
            { Id: id },
            function (json) {
                if (json.recode == "1") {
                    alert("删除成功!");
                    //parent.location.reload();此处可以自动刷新页面
                    $("#t"+id).remove();
                } else {
                    alert("删除失败!");
                }
            },
            "json"
            );
        }
    </script>
后台代码:
1 /// <summary> 2 /// 读取用户列表 3 /// </summary> 4 /// <param name="context"></param> 5 public void ProcessRequest(HttpContext context) 6 { 7 context.Response.ContentType = "text/html"; 8 9 string id =context.Request.Form["Id"]; 10 if (UserInfoManager.DeleteUserInfoById(Convert.ToInt32(id)) > 0) 11 { 12 context.Response.Write("{\"recode\":\"1\"}"); 13 } 14 else 15 { 16 context.Response.Write("{recode:'2',content:'删除失败'}"); 17 return; 18 } 19 }
效果图:

    作者:江宁织造 
博客:http://www.cnblogs.com/wgx0428/
博客:http://www.cnblogs.com/wgx0428/

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号