javascript通过ajax调用删除服务器上的文件

I am trying to delete files on the SERVER by javascript, and I already read the tips from delete files by javascript

My part of javascript is current looks like that,

deleteFile = function() {
  return $.ajax({
    url: "delete.php"
  }).success(function(responce) {
    if (responce === 'deleted') {
      return alert("deleted");
    }
  });
};

And my "delete.php" is looks like that

<?php
  if unlink("data/hello.json")
     print "deleted"
?>

And I am using commend python3 -m http.server 8000 to setup server.

When I perform deletion, which run the function deleteFile(), and I got the following message in terminal, localhost - - [01/Dec/2015 17:19:17 "GET /delete.php HTTP/1.1" 200 -

That means the "delete.php" can be "GET" correctly, right? However, "data/hello.json" still exist, that means "delete.php" did not execute. I also check if "delete.php" is executable by using commend php -f delete.php , and it works, "data/hello.json" is deleted ! That means there should be no problem with my php script.

I am wondering where I went wrong.

Thanks

This file could be accessed by some process and on Linux systems will be deleted when process closes this file.

In addition to that. You should not be using HTTP GET method for anything which changes data state. You can use POST or DELETE methods instead.

Also I don't see any user authorisation being done. Do you indend anyone to be able to delete you files?