Hi, This questions is bit specific to joomla.
I have created the custom error page error.php in /template/MY_TEMPLATE/error.php. This file checks for the error codes and displays different message for each http code I set(I check with $this->error->code == '404'). Normally this works good.
Now the question is, how should I handle same thing when I am using ajax? When I do an ajax call if an error occurs, I would get http status code back, and the response is the error.php file output. When I get error I would like to redirect the user to the error.php (custom error page) with proper error codes, which would display the messages accordingly!
Scenario : - I am requesting an ajax call to a component with a task (com_greatsuff), which executes some webservice calls to get list of stuff based on itemcode provided. If the itemcode is not found on webservice it woud return 404 Error.(There are many other custom error codes). If it was not an ajax call, it works good as i raise error(JError::raiseError), and displays custom error page. But on ajax call, it will return http status(404) but i need to redirect from javascript with the proper http header. Thanks, Tanmay