title: PHP show response of script in ajax call
body: <p>I do an ajax call to my script to upload a file, now I want to show some feedback of certain checks like if the file already exists. </p>
  
  <p>I can't get it to show the response of my script. Why is the response not showing?</p>
  
  <p>Here is my ajax call:</p>
  
  <pre><code>$(document).ready(function()
  {
      $("#upload").submit(function(e)
      {
          e.preventDefault();
  
          $.ajax(
          {
              url: "upload.php",
              type: "POST",
              data: new FormData(this),
              contentType: false,
              cache: false,
              processData:false,
              success: function(data)
              {
                  //i want response here true or false
                  location.reload(true);
              }
          });
      });
  });
  </code></pre>
  
  <p>the <em>upload.php</em> script:</p>
  
  <pre><code>&lt;?php
  
  $dir = 'files';
  
  echo upload();
  
  /**
   * Upload a file
   *
   * @return bool
   */
  function upload()
  {
      // Storing source path of the file in a variable
      $sourcePath = $_FILES['file']['tmp_name'];
  
      // Target path where file is to be stored
      $targetPath = "files/".$_FILES['file']['name'];
  
      // Check if file already exists
      if (file_exists($_FILES['file']['name'])) {
          return false;
      }
  
      // Moving Uploaded file
      move_uploaded_file($sourcePath,$targetPath) ;
  
      return true;
  }
  </code></pre>