- The front desk clicks on the file, jquery deletes the corresponding real files in the background, contains 2 pages, one is the page that displays the picture, the other is the page that passes the file name and then deletes the real picture. The specific code is as follows:
- Showpics.htm:
- <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
- <HTML xmlns="http://www.w3.org/1999/xhtml" >
- <head>
- <title>untitled Page</title>
- <script src="js/jquery-1.4.4.js" type="Text/javascript"></ Script>
- <script src="js/json2.js" type="Text/javascript"></script>
- <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>
- </head>
- <body>
- <div>
- <img src= "images/xiyangyang.jpg" alt="xiyangyang.jpg" />
- </div>
- </body>
- </html>
- The code for the specific deleted page is as follows:
- 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 ();
- }
- }
jquery with ASP. NET No refresh delete files on the specified server!