AJAX / PHP服务器问题

Okay so, I have made a cPanel like file manager. The main difference is I have all the source code for it and I can manipulate it at my leasure. My issues is my save function for my text editor. I am using ACE-editor. I have no problem getting the value of the editor but submitting it via, aJax request has been hell for me. The save function is the following.

if(isset($_POST['text'])  && isset($_POST['location'])){
   $location = $_POST['location']; //this also contains the file name 
   $contents = fopen($location, 'w') or die("can't open file");
   $submitedData = $_POST['text']; // this contains the editor's text
   fwrite($contents, $submitedData); 
   fclose($contents); 
}

The aJax request is the following

$.ajax({
  url: "edit.php",
  type: 'POST',
  data: {
    'text': e.getValue(),
    'location':$('#saveValue').val()
  },
  success: function () {
    errorReport("File has been saved!");
  },
  error: function (){
    errorReport("Failed to save file");
  }
}); 

Some need to know things

  • editor = <div id="e"></div>
  • SaveValue = <input type='text' id="saveValue" value="<?= $_SERVER['DOCUMENT_ROOT'].$_GET['dir'];?>">
  • var e = ace.editor("e");
  • $_POST['test'] = e.getValue();
  • $_POST['location'] = ('#saveValue').val();
  • $_GET['dir'] is the current directory you're in e.g. /path/to/files/index.php/

but it does not include the path before the like /public_html so /home/user/www/public_html is hidden

So, now that you know the basics of how it works. when I do my ajax call on Ace's keyboard shortcut Alt + S It submits my ajax request. My issue is when it submits it the request times out. Like it doesn't know where to submit it and it is frustrating me because I am getting NO error back any where. These functions have worked in the past but now they are timing out and failing to save ANYTHING. I am hoping that I made a mistake in my code somewhere.

So my question is: Why would ajax appear to timeout on a request like I seem to be getting, and how can I fix this problem? ( I submitted the page to try to see how long I would have to wait for it to get a response it took >15 minutes to anything back from the page, and that was a time out error.)