I've run into a difficult issue with ajax. I've got 2 files. 1 file calls the other, using the .ajax api. So far I have no issues.
The problem I'm running into is due to how I return a response to the ajax, from the 2nd file. Usually I use the php "return" function. Which then lets me decide what to do with that text. However, I really really want to use the die() function on the 2nd file.
File 1:
$.ajax({
type:"POST",
url:"/myfile.php",
data:"formId=processorder",
error:function(){alert("error occurred");},
success:function(response){alert(response);}
});
File 2: (myfile.php)
<?php
// this does not work
die("Message I want to return");
// this does work, but don't want to use it
return "Message I want to return";
?>
I want to use die() because it stops the process completely. Am I doing something wrong?
I suppose doing both would possibly be the work-around. But that seems a little overkill. So, I thought I'd ask first.