i am calling struts2 action from jquery ajax on success it returns string and on error it should be dispatched to same page and should display errors. i have used following code check it..
$(document).ready(function(){
$('#getActionRs').click(function(){
alert("call action");
$.ajax({
type:"POST",
url: "returnToAjax",
data: "firstinput=" +$('#firstinput').val()+"&secondinput=" +$('#secondinput').val(),
success: function(msg){
alert("success:"+msg);
}
});
});
});
i have used above code to call my struts action. onclick of button this thing get called
i have specified my action element in config file as follows
<action name="returnToAjax" class="example.returnToAjax">
<result name="success" type="stream">
<param name="contentType">text/html</param>
<param name="inputName">inputStream</param>
</result>
<result name="input" type="dispatcher">/Login.jsp</result>
</action>
when it returns success it return string correctly, i have done some validation of this action by validation xml but when it returns error it just shows me Login.jsp file code it does not dispatches it to Login.jsp