龙空技术网

删除重传图片,局部刷新DIV

洞悉科学 111

前言:

现在各位老铁们对“ajax调用ashx方法”大概比较重视,大家都需要分析一些“ajax调用ashx方法”的相关内容。那么小编在网络上搜集了一些有关“ajax调用ashx方法””的相关内容,希望姐妹们能喜欢,兄弟们一起来学习一下吧!

​一、html

 <a href="javascript:;" onclick="reupload()">删除重传</a></div>

二、jquery

//删除重传代码       function reupload() {           var uppath = document.getElementById("<%=HiddenField1.ClientID%>").value;           alert(uppath);           $.ajax(          {               type: 'get',               url: 'reupload.ashx',               contentType: "application/json;charset=utf-8",               dataType: "text",               data: { path: uppath},               success: function (data) {                   alert(data);                   $("#tu").load(location.href + " #tu");  //局部刷新DIV                               },               error: function () {                   alert("出错了!请稍候再试!");              }          }          );      }

三、ashx

public void ProcessRequest(HttpContext context)      {           context.Response.ContentType = "text/plain";           string file_path = context.Request.QueryString["path"];           string strpath = System.Web.HttpContext.Current.Server.MapPath(file_path.Replace(@"/", @"\"));           System.IO.FileInfo file = new System.IO.FileInfo(strpath);//获得文件对象           if (file.Exists)          {               file.Delete();//删除磁盘文件               context.Response.Write("删除成功!");          }           else          {               context.Response.Write("失败!");          }      }

四、renderings

标签: #ajax调用ashx方法