Differentiate between success data and error message to use in Struts 2?

Viewed 305

I am doing an AJAX call and using Struts2 JSON plugin.

When the code reaches success() of AJAX call, I don't know how to differentiate whether I should load the success data or load message or errors, which I want to display it to the user if something unusual happened during the AJAX call.

As code always reaches success() until the AJAX request itself fails.

How can I achieve this?

EDIT: I came up with one idea which was to send a String too with response to Ajax and check string value (i.e) if string is set to success load the other JSON parameter returned, if error I load error.jsp

1 Answers
Related