Marta -

Remember, an Ajax request/response is a separate processes and does
not affect the current page state. It happens "behind the scenes".

If you took my example and looked to see what was in the response
(resp), you would see that contains the results of jsp-listreports.do.

If you want the result of your request to load a new page, there are a
bunch of different options. One option would be to have the result of
your action return a success/failure message or the URL of the action
to call/failure message. I see you have dataType as xml, so you could
have your action return something like:

<response>
  <success>/jsp-listreports.do</success>
</response>

$.ajax({
  url: '/listReports.do',
  type:'post',
  cache: false,
  dataType:'xml',
  success: function (resp) {
    // sudo code:
    // parse xml for the success node
    if (success) {
      window.location = test of success node
    }
    else {
      // provide an indication that there was a failure
    }
  }
});

On Dec 5, 6:16 am, Marta Figueiredo <[EMAIL PROTECTED]> wrote:
> I'm trying to call a struts action using ajax. The action is correctly
> called. The problem is that the action forward method is called but it
> is not executing.
> My action is defined as follow:
>
>  <action path="/jsp-listreports"
> parameter="/WEB-INF/reportmanagement/listreports.jsp" scope="request"
> type="weboncampus.action.reportmanagement.ForwardActionReports" />
>         <action path="/listReports"
> type="weboncampus.action.reportmanagement.ActionGetReportsList"
> scope="request">
>             <forward name="list" path="/jsp-listreports.do"
> redirect="false"/>
>         </action>
>
> Shouldn't the page be automatically redirected to listreports.jsp after
> calling listReports.do?
>
> Marta
>
> Eric Martin wrote:
> > Marta - what exactly are you trying to do? By using an Ajax call, you
> > are going to get a response that should be the output of the forwarded
> > action.
>
> > $.ajax({
> >   url: '/listReports.do',
> >   type:'post',
> >   cache: false,
> >   dataType:'xml',
> >   success: function (resp) {
> >     // do something with resp
> >   }
> > });
>
> > -Eric
>
> > On Dec 4, 10:32 am, Marta Figueiredo <[EMAIL PROTECTED]> wrote:
>
> >> Hi
>
> >> I need to call an action using jquery..
>
> >> The following piece of code works correctly for it is calling and
> >> executing code the correct struts action. However.. the action itseft is
> >> not being correcty forwarded. I don't think that the problem is the
> >> action, for if I call it in other ways the forward works. Any ideas?
>
> >> $.ajax({
> >>                url: '/listReports.do',
> >>                type:'post',
> >>                cache: false,
> >>                dataType:'xml'
>
> >>            });
>
> >> thanks
> >> Marta

Reply via email to