jquery ajax ashx

        function DivRemove(obj, str) {      
            var text = obj.name;
            var formdata = new FormData();
            formdata.append("myText", text);
            var ajax = new XMLHttpRequest();
            ajax.open("POST", "Dol.ashx");
            ajax.send(formdata);

            var newobj = '#' + str
            $(str).remove();
        }


<%@ WebHandler Language="VB" Class="Dol" %>

Imports System
Imports System.Web
Imports System.IO
Imports System.Web.SessionState

Public Class Dol: Implements IHttpHandler, IRequiresSessionState
   
  Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        Dim savepath As String = ""
        Dim tempPath As String = ""
        tempPath = System.Configuration.ConfigurationManager.AppSettings("FolderPath")
        savepath = context.Server.MapPath(tempPath)

        Dim FileName As String = context.Request("myText")
        'Dim FileNameArr As String() = Split(FileName, "\")
        'FileName = Format(Now, "yyyyMMdd HHmmss") & "." & FileNameArr(FileNameArr.Length - 1)

        If File.Exists(savepath & "\" & FileName) = True Then
            File.Delete(savepath & "\" & FileName)
        End If

    End Sub

    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class

沒有留言:

張貼留言