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();             }   

          }

  • 相关阅读:
    PgSql备份pg_dump与还原手记pg_restore(转)
    精通 JS正则表达式(转)
    88个常用英语词语搭配
    C3P0 代码分析
    windows 域名+虚拟目录 (php)
    postgresql 查询字段中的某些数据
    Memcached 在windows下的安装 支持 phpwind 后台Memcache 缓存配置
    正则表达式学习笔记
    Word2007快捷键大全
    Windows 版本说明
  • 原文地址:https://www.cnblogs.com/dongbo19910728/p/2958374.html
Copyright © 2011-2022 走看看