I am working in Struts2 webapp and while trying to send mail it's not working on first click where as when I clicked second time it's working and aslo if I comment the <interceptor-ref name="token" /> then it's working on first click.

NOTE: 1. On first click working only if I comment<interceptor-ref name="token" />

Here's my struts.xml code

<action name="myActionName" class="actions.myActionName"
            method="myActionName">
            <interceptor-ref name="token" />
            <interceptor-ref name="params" />
            <interceptor-ref name="basicStack" />
            <exception-mapping result="passRecoveryException"
                exception="exceptions.PasswordRecoveryException" />
            <result name="success" type="json" />
            <result name="passRecoveryException" type="json" />
            <result name="invalid.token">/index.jsp</result>
        </action>

and I'm sending mail from frontent using jquery

$(document).on('click','#myActionNameId',function(){
    if($("#username").val() == ""){
        showToaster(2,"This field is required."," User name");
        return false;
    }else if ($("#email").val() == ""){
        showToaster(2,"This field is required."," Email ID");
        return false;
    }/*else if ($("#captchaText").val() == ""){
        showToaster(2,"This field is required."," Captcha");
        return false;
    }*/else if(grecaptcha.getResponse().length==0){
        showToaster(2,"Please verify your captcha","Captcha");
        return false;
    }
    
    else{

        $('#loading').show();
        var form = $('#forgotPassForm');
        var formdata = false;
        if (window.FormData){
            formdata = new FormData(form[0]);
        }
        var formAction = form.attr('action');
        submitByAjaxWithConfirmwithCallBackJSON(formAction,formdata,function(data){
            //alert(data.exception);
            if(data.exception==undefined){
                 if(data.success==true){
                    $('#loading').hide();
                    showToaster(1,data.message.split(':')[1],data.message.split(':')[0]);
                 }else{
                     showToaster(2,data.message.split(':')[1],data.message.split(':')[0]);
                     $('#loading').hide();
                 }
            }else{
                var msg = data.exception.message.split(':');
                showToaster(2,msg[1],msg[0]);
                //alert(msg[0]);
                $('#loading').hide();
            }
        })
    }
});

on first click it's going to

 if(data.success==true){
                    $('#loading').hide();
                    showToaster(1,data.message.split(':')[1],data.message.split(':')[0]);
                 }else{
                     showToaster(2,data.message.split(':')[1],data.message.split(':')[0]);
                     $('#loading').hide();
                 }

else part but after second time when I again click to send it's working fine.

0

There are 0 best solutions below