title: Is it possible to return value from PHP to Ajax after error 500?
body: <p>This Ajax is sending some data to php file and getting back the response that is showed in my html. Everything is working fine but sometimes I have been getting Error 500 response from php file. I know why and it is ok because as you can see after error 500 I'm calling the Ajax function again. </p>
  
  <p>My question is. Is it possible to return from php file also some data after getting error 500? By data I mean variable returned from php file when the error occured. </p>
  
  <pre><code>function tr() {
   var vysledok = document.getElementById('vysledok_body');
   var text= document.getElementById('source').value;
   var languageFrom = document.getElementById("src").value;
   var languageTo = document.getElementById("dst").value;
   vysledok.innerHTML="";
   var xmlhttp = new XMLHttpRequest();
   xmlhttp.open('GET', "https://.... someurl.php?
   from=" + languageFrom + "&amp;to=" + languageTo + "&amp;text=" + text, true);
   xmlhttp.onreadystatechange = function() {
  
  if (xmlhttp.readyState == 4) {
    if(xmlhttp.status == 200) {
        var obj = JSON.parse(xmlhttp.responseText);
        console.log(obj.ip);
        vysledok.innerHTML = "&lt;p class='bdr'&gt;"+obj.text+"&lt;/p&gt;";
    }
  if(xmlhttp.status == 500) {
      //console.log('nejde');
      tr();
    }
  }
   };
   xmlhttp.send(null);       
  }
  </code></pre>