Yii Framework Forum: How to redirect after the ajax request? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to redirect after the ajax request? Rate Topic: -----

#1 User is offline   Jaime 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 15-August 09

Posted 27 August 2009 - 10:17 PM

Hello.... using EHtml wrapper I put this instruction:

<?php echo EHtml::ajaxSubmitButton($update ? 'Almacenar' : 'Crear', '', 
                                   null, array('class'=>'boton')); ?>


The ajax submit works perfectly, but after storing the form into the database table, I need the browser to be redirected to the "admin" page. I know that it is possible since demo pages shows that it is possible to execute a JavaScript function after successful submit, so I could place a location.href there, but, those demo pages doesn't show the PHP code to use to get the corresponding behaviour.

Any help, please?
Thanks
Jaime
0

#2 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 28 August 2009 - 01:41 AM

Just replace this submit button with regular one, and redirect the user as you wish.

Ajax is used to save the cost of page reloads. In this context it does not make any sense.
0

#3 User is offline   Jaime 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 15-August 09

Posted 28 August 2009 - 08:37 AM

thanks for replying... I had the regular submit button, but I had problems with a "cancel" button which must return to the previous page (only by executing a history.back() instruction)

If I use a regular button, and form validates incorrectly, "cancel" button stays at the form. So the question may be other: why can jformvalidate be used to validate using Ajax?. Maybe I am configuring it incorrectly.

I think about 2 possibilities.

- Field is validated in onblur() of each field contained in the rule (using Ajax) and the submit button is enabled only if all data is correct, or..

- when pressing submit, whole validation is perfomed using Ajax and if validation is correct, the normal submit behavior is executed.

is it possible to do one of those approaches, or both, using jformvalidate extension?

Thanks
Jaime
0

#4 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 28 August 2009 - 08:53 AM

Why not store the returnUrl before the user is shown this form? That way you could provide a link to cancel.

It may be also acceptable if just guess the url the user had been visiting.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users