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

          }

  • 相关阅读:
    Jenkins理解逻辑图
    什么是Jenkins?
    SpringBoot Test及注解详解
    如何熟悉一个新项目
    调用百度OCR模块进行文字识别
    python安装包的方法&安装遇到的问题总结_2020_11_19
    怎么让谷歌浏览器记住密码(不需要任何插件)
    excel以一列数据为x一列为y作折线图
    java创建新java文件的方法
    Mathematics释放变量的方法
  • 原文地址:https://www.cnblogs.com/dongbo19910728/p/2958374.html
Copyright © 2011-2022 走看看