Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When you're making an AJAX request, you just get a response containing some kind of data, which is interpreted by scripts on the client side.</p> <p>So, in case on error, the only thing that the server can do is send the error in the response to the ajax request.</p> <p>At this moment, the client-side script receives the error information and you can use it the way you like. You're doing it the right way.</p> <p>However, if you need to take some extra actions, like logging the error, you have two options:</p> <p>1) send the error back to the server from the javascript: for example you could use aregular form with an input of type hidden, set the input value, and post the form using form.submti() to your error page. Your page can recover the contents of the hidden field using the Page's Request object and process it.</p> <p>2) catch the error on server side, within try/catch, or page_error or application_error events, log the exception, or whatever you want to do with it, and throw a new exception that will arrive at the client side, hiding the original exception info.</p> <p>The second option is cleaner and safer, as you don't send error information to the browser.</p> <p>Think that the server can't redirect the browser in any way because when the server is sending a reponse to an AJAX request the server isn't rendering a new page for the browser,and the browser is not receiving a new whole page. The server is simply sending some information to be processed by client-side scripts. So your script is responsible for reloading a new page or whatever you need to do.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload