I would like to send the results of the validate() method of an action as (JSON?) data to the ajax call on the client side so that I can inform the user.
I am sending form data in the client side through ajax. In the server side I am implementing a simple validate() method (I am no ready for a validation framework yet). This is my ajax call
function save_new_user() {
    var user = 
    {       username: $('#new_user_username').val(),
            email: $('#new_user_email').val(),
            password: $('#new_user_password').val()         
    };
    data = {'user':user}; 
    datastr = JSON.stringify(data);
    $.ajax({
        type : 'POST',
        url : 'SaveNewUser',
        data: datastr,
        dataType : 'json',
        contentType: 'application/json',
        success : function(data, textStatus, jqXHR) {
            if(data) {
            }
        },
        error: function(jqXHR, textStatus, errorThrown) {
            console.log(errorThrown);
        }
    });
}
And in my Struts2 Action I have
public void validate() {
    if(user.getUsername().length() < 6){
        addFieldError("user", "username must be at least 6 charachers long");
    }
    if(user.getPassword().length() < 8){
        addFieldError("user", "password must be at least 8 charachers long");
    }
}
/* Execute */
public String execute() throws Exception  {
    dbServices.saveUser(user);
    return "SUCCESS";
}
I have a default stack being applied to this action call
<package name="json-data" extends="json-default">
    <interceptors>
        <interceptor-stack name="jsonDataStack">
            <interceptor-ref name="json"/>
            <interceptor-ref name="basicStack"/>
            <interceptor-ref name="validation">
                <param name="excludeMethods">input,back,cancel</param>
            </interceptor-ref>
            <interceptor-ref name="jsonValidation"/>
            <interceptor-ref name="workflow"/>
        </interceptor-stack> 
    </interceptors>
    <default-interceptor-ref name="jsonDataStack"/>
</package>
and the validate() method is being called.
So, here is my question once again: how can I send the results of the validate() function as data to the ajax call so that I can use it to inform the user?. It seems that the method addFieldError() is not configuring the data in a JSON readable form since the error message in the ajax result is
SyntaxError: Unexpected token <(…)