title: Redirecting to error page within ajax request
body: <p>I am using jQuery's ajax functions to make my ajax request.</p>
  
  <p>My question is if I caught an error how do I then redirect to a error page, say I've got the error, logged it, and now want to redirect to a error page, is it possible within the ajax request or will it just redirect the request not the page performing the request?</p>
  
  <p>Do I have to state an error has occurred within the request, by changing the headers HTTP status to say 500 then within the ajax error function direct to a error page?</p>
  
  <p>However within my ajax request if I have already echoed out data and then want to change the header information, will cleaning the buffer allow me to then change the headers? </p>
  
  <p>Is this how I would clean the buffer?</p>
  
  <p><code>if(ob_get_length()) ob_clean();</code></p>
  
  <p>How I normally redirect, include a error page :</p>
  
  <pre><code>header('HTTP/1.1 500 Internal Server Error', TRUE, 500);
  readfile("500.html");
  </code></pre>
  
  <p>Within my ajax request would I just change the header like above and then deal with the rest with jQuery?</p>