I have two PHP files to manage my files on a server:
list.php
delete.php
The file "list.php" shows a list of files in a specific directory of server. It uses a table to list the files. One of the columns in the table is named "Delete this file". If you click on that column in a row, the file "delete.php " with an argument will be called. It will delete the file passed to it through address bar arguments.
This is an easy example of "list.php"
How can I change this code to an Ajax-enabled one. I wish to click on the "Delete" column. It should then run "delete.php " with its arguments behind the scene without refreshing the current "list.php" page. When the file was deleted, I can use a JavaScript function to delete the current row of the current column.
I know nothing about AJAX. It's too complicated for me.
How can I do this with AJAX or JQuery?
Thank you in advance.
list.php
delete.php
The file "list.php" shows a list of files in a specific directory of server. It uses a table to list the files. One of the columns in the table is named "Delete this file". If you click on that column in a row, the file "delete.php " with an argument will be called. It will delete the file passed to it through address bar arguments.
This is an easy example of "list.php"
Code:
<html>
<head>
<script type="text/javascript">
<!--
function KillFile(delFile) {
var answer = confirm("Delete this file? \n <?php echo $_GET["fname"]; ?>")
if (answer){
alert("File was deleted!");
window.location = "Delete.php?fname=" + delFile ;
window.location = "list.php";
}
else{
window.location = "list.php";
}
}
//-->
</script>
</head>
<body>
<form>
<input type="button" onclick="KillFile(fileName)" value="Delete">
<input type="button" onclick=window.location="list.php" value="Cancel">
</form>
</body>
</html>
How can I change this code to an Ajax-enabled one. I wish to click on the "Delete" column. It should then run "delete.php " with its arguments behind the scene without refreshing the current "list.php" page. When the file was deleted, I can use a JavaScript function to delete the current row of the current column.
I know nothing about AJAX. It's too complicated for me.
How can I do this with AJAX or JQuery?
Thank you in advance.
Comment