so consider this case:
The workspace is a website similar to Google Drive. (Keep that in Mind)
I have a Delete .icon
to delete a file from my files list,
and as soon as i request delete file WebMethod using Ajax i would like to also retrieve the new files array, within the same response.
So far i have Tried this.
consider also that the work flow is -
1- request Delete file using Ajax from the Element ID
2- after deleting (that is successfully already done) i call another function that retrieve the files from their RealPath
RealPath : is where those files Placed on the serve.
So far this is the code i have Tried.
$(".fa-trash-o").click(function () {
var ID = $(this).closest(".ImageBlock").attr('id');
var path = $(this).closest(".ImageBlock").attr('Get')
var RealID = parseInt(ID);
$.ajax({
type: "POST",
url: "../../Home.aspx/DeleteFile",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({ 'ID': RealID, 'RealPath': path }),
success: function (result, xhr, request) {
OnSuccess(result.d);
}
});
});
and this is my Back-end webMethod
public static string DeleteFile(int ID, string RealPath)
{
try
{
FilesBAL FilesBAL = new FilesBAL();
if (FilesBAL.Delete(ID) == true) {
return GetDataByParent(RealPath);
}
else
{
return Statment.Error_Delete;
}
}
catch (Exception ex)
{
return Statment.Error_Delete;
}
}
GetDataByParent: A method that returns Data serialized as JSON
Additional info might be needed: i am using
MySql
StoredProcedures to execute theDB
queries.
What are the Steps to check on that ?
Since the same method (GetDataByParent
) used before to get the home page files is used when deletion occur, And it works 100% fine everywhere else.