Hello,
I am trying to delete directories using jquery, it does delete and stays on the 1a.php, which executes the code for the delete. What I exactly want is a delete of directory without page refresh, and display a message the directory has been deleted.
Please let me know what I am doing wrong here.
Thanks in advance Dave
Please find the code below
// ----------------------------------1a.php
if ($_POST['al_del']) {
$dir = $_POST['al_del'];
//preg_replace('/(\d+)/', '', $_POST['al_del']);
rmdir('$dir_path/'.$dir);
echo 'album deleted';
}
//-----------------------------------1.php where the directories are listed
<script>
$('#album_del_form').ajaxForm({
target:'#dir_del',
success: function() {
$('#dir_del').fadeOut(40000);
}
});
</script>
<div style=" position:relative; top:20px; left:0px; background-color:#BBBBBB; font-family:'Arial Rounded MT Bold'; font-size:12px;">Current Albums</div>
<div style=" position:relative; top:20px; left:4px; font-family:'Arial Rounded MT'; font-size:12px;">
<?
$album_path1 = "$dir_path/";
$cur_dir = opendir($album_path1);
chdir($album_path1);
$i_count=0;
while (($file = readdir($cur_dir)) !== false) { ?>
<? if (($file != ".") && ($file != "..") && (is_dir($file))){ $i_count=$i_count+1; ?>
<div id="dir_del">
<form name="album_del_form" id="album_del_form" method="post" action="1a.php">
<input type="image" src="images/delete.gif" name="al_dell" id="al_dell" value="<? echo $file; ?>"/><? echo $file; ?>
<input type="hidden" id="al_del" value="<? echo $file; ?>" /></form>
</div>
<? }
} ?>
<div id="dir_del"></div>
</div>
</div>