coolmego coolmego - 4 months ago 21x
Ajax Question

Struts2 success page not getting invoked

I am invoking struts2 action from jquery-ajax, the action method method getting invoked properly but unfortunately the action success page is not getting invoked. The js method is the one I use for google OAuth2.0.

JS :

function onSignIn(googleUser) {
// Useful data for your client-side scripts:
var profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId()); // Don't send this directly to your server!
console.log('Full Name: ' + profile.getName());
console.log('Given Name: ' + profile.getGivenName());
console.log('Family Name: ' + profile.getFamilyName());
console.log("Image URL: " + profile.getImageUrl());
console.log("Email: " + profile.getEmail());

// The ID token you need to pass to your backend:
var id_token = googleUser.getAuthResponse().id_token;
console.log("ID Token: " + id_token);
console.log("Request sent through ajax jquery");

type : "POST",
url : "googlesignup",
dataType : "text",
async: false,
// onSuccess:function(){
// console.log("success");
// }

struts.xml :

<action name="googlesignup" class="com.msventure.web.actions.SignUpAction" method="googleSignUp">
<result name="success">/buildprofile.jsp</result>
<result name="fail">/signup.jsp</result>
<result name="index">/signup.jsp</result>
<result name="input">/signup.jsp</result>

Update :

  1. I just checked, i am setting some cookie value in the action method, the cookies are getting updated in the client.However, the response from the success is buildprofile.jsp, it should be changed but it displays the last page.

  2. The response to ajax is now going to the error callback function.

Your suggestions highly appreciated.


First make sure the url is correct action, it seems that url : "googlesignup"needs to be some thing like: url : "googlesignup.action", you can test it manually by typing its url in address bar and check if you see the result which is buildprofile.jsp.

Second you need to define the correct success method to show the final result page. like

       success: function(result){

Make sure you have a <div id="someDiv"></div> in your page.