zoukankan      html  css  js  c++  java
  • 前台单击文件,jQuery删除后台相应真实的文件

     Untitled Page

        <script type="text/javascript">
            $(function() {
                $("body img").click(function() {
                    var name = $(this).attr("alt");
                    $.ajax({
                    url: "DeletePicsForm.aspx",
                        data: "picname="+name,
                        datatype: "json",
                        type: "GET",
                        contentType: "application/json; charset=utf-8",
                        success: function(data, textStatus) {
                            alert(data.result);
                        },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest);
                        }
                    });
                });
            });
        </script>

    DeletePicsForm.aspx.cs:

      protected void Page_Load(object sender, EventArgs e)         {      

           if (Request["picname"] != null)             {    

                 Response.Clear();             

               Response.ContentType = "application/json";     

               String result = "success";               

             try                 {          

               File.Delete(Server.MapPath(@"\Images\")+Request["picname"].ToString());       

              }             

           catch (Exception ee)                 {   

               result = ee.Message;       

              }             

            Response.Write("{\"result\":\"" +result+ "\"}");     

                Response.End();             }   

          }

  • 相关阅读:
    避免文本字体大小重置
    为webapp应用制定IOS,Android桌面快捷图标
    兄弟节点 疑问的
    节点属性
    区别getElementByID,getElementsByName,getElementsByTagName
    三种快排四种优化(转载)
    快排(模板)
    二分法求解最大值或最小值(模板)
    中国剩余定理(转载)(中国剩余定理与扩展欧几里德的联系)
    简单母函数(转载)
  • 原文地址:https://www.cnblogs.com/dongbo19910728/p/2958374.html
Copyright © 2011-2022 走看看