title: PHP Return Value from Controller to Ajax
body: <p>I am using a MVC and I have a button that is using an AJAX call to remove an uploaded image on the site.</p>
  
  <p>This is my Model:</p>
  
  <pre><code>public function remove_document($documentID, $documentName)
      {
          $objData = $this-&gt;objDB
              -&gt; setStoredProc('attritionRemoveDocument')
              -&gt; setParam('documentID', $documentID)
              -&gt; setParam('documentName', $documentName)
              -&gt; execStoredProc()
              -&gt; parseXML();
  
          return $objData-&gt;data-&gt;response;    
  
      }
  </code></pre>
  
  <p>The response back from this is either <code>true</code> or <code>false</code>.</p>
  
  <p>Here is my controller:</p>
  
  <pre><code>public function deleteFile()
      {
          // Get the documentID we are removing
          $documentID = $this-&gt;input-&gt;post('documentID');
          $documentName = $this-&gt;input-&gt;post('documentName');
  
          // Check if the file is even there
          if (file_exists('./uploads/'.$documentName)){
  
              // Remove file
              unlink('./uploads/'.$documentName);
              $removeFile = $this-&gt;submit_model-&gt;remove_document($documentID, $documentName);
  
              return $removeFile;
  
           }
  
     }
  </code></pre>
  
  <p>And finally, my AJAX Call:</p>
  
  <pre><code>$('[name=deleteDocument]').click(function() {
  
          var documentID = $(this).attr('documentID'),
              documentName = $(this).attr('documentName');
  
          //Delete the image
          $.ajax({
              type: 'POST',
              url: '../deleteFile',
              dataType: 'xml',
              data: {
                  'documentID': documentID,
                  'documentName': documentName
              },
              success: function(msg) {
  
                  // On Success, remove the current file section
                  console.log(msg);
  
              }
  
          });
  
      });
  </code></pre>
  
  <p>When i <code>echo</code> the <code>$removeFile</code> value in the controller, I see the <code>true/false</code> value however it never makes it to the success function of the AJAX call.</p>
  
  <p>Any ideas?</p>