Hi
I’m working on an application with Java as it’s server-side language and for the client-side I’m using Ajax.
But I’m fairly new to ajax applications so I needed some opinions on the issue I’ve faced.
I’m using Spring Security for my authentication and authorization services and by reading spring forums I’ve managed to integrate Spring Security with Ajax application in a way that ajax requests can be intercepted and relevant action be taken.
Here’s the issue: What is the best way to let the ajax application know that an error has occurred back at server. What I’ve been doing so far is that by convention I make random http 500+ errors. e. g. to prompt for login I return 550, and 551 for other issue and so forth. But I think this is not the right approach to this. What is the best approach for dealing with this situation?
Hi I’m working on an application with Java as it’s server-side language and for
Share
If standard HTTP error codes (eg 401 Unauthorized) are rich enough, use them. Best not to make up your own HTTP error codes, they’re meant to be fixed. If you need more info to be returned, you should return a richer object in the response body (serialized as eg JSON or XML) and parse the object on the client side.