.get() result evaluation if statement always returns false

.get() result evaluation if statement always returns false

I have a script that grabs a file name and guid from the page when the user changes the input type=file selection to upload a file.  It calls a php page that checks a mssql database to see if there is already an entry for that file and guid.  If there is it echos "exists".  The script gets that value (I put an alert after the get() and it shows the expected response text).  However, the if statement right after the alert doesn't register as true.
 
Aaaaah!  I tried using numbers instead of text and I tried putting the if statement inside a separate function to see if that made any difference.  Still not evaluating properly.
 
Please help - even a suggestion of another way to evaluate the existence of the file... maybe .get() isn't the best way to do this.
 
Code follows.....
 
function docCheck(){
 var attachfilepath = document.getElementById("AttachFile").value;
 var docguid = document.getElementById("DocGuid").value;
  //cut the file path down so just get the filename
 attachfile = attachfilepath.substr(attachfilepath.lastIndexOf("\\")+1);



 // Check to see if file exists.
 
 $.get("Doc_Check.php", {guid:docguid, filename:attachfile}, function(file_exists){
  alert(file_exists);
  if(file_exists=="exists"){
   if(confirm("The file \"" + attachfile +"\" already exists.  Would you like to replace it?")){
    document.getElementById('docReplace').value = "true";
   }else{
    return false;
   }
  }else if(file_exists == "deleted"){
   document.getElementById('docReplace').value = "true";
  } 
 });
 var rreplace = document.getElementById('docReplace').value;
 alert (attachfile);
 alert (docguid);
 alert (rreplace);
}

















 
Doc_Check.php - without mssql query section
 
// if there's a result then there's an entry of some kind
  if(mssql_num_rows($result)!=0){
   $row=mssql_fetch_array($result);
   if ($row['Delete_Date']){echo "deleted";}
   else{echo "exists";}
  }else{ echo "does not exist";}





when run by itself this page shows just the text exists, deleted, or does not exist as expected... the alert if the get statement also shows the same value.