Reputation: 538
I am struggling for simple redirecting page in symfony using ajax...but before redirecting we must save the form ..i dno how to cal action using jquery ajax to save the form and redirecting to another form... i dno to handle this in symfony framework...
any one help me in prob...
Upvotes: 0
Views: 4699
Reputation: 6923
IMHO not everything must be done with AJAX.
... to save the form and redirecting to another form ...
You can handle your form request as usual with the corresponding action
if($form->isValid()){
/*
do things
*/
$this->redirect("routeto/nextform");
}
Otherwise take a look at martin-b's answer
Upvotes: 1
Reputation: 4588
With jQuery: I would post your Form via $.ajax
and pass the destination with Symfony's url_for
. In the callback you could redirect to another action.
$.ajax({
type: 'post',
url: '<?php echo url_for('your/action') ?>', // where to post form data
data: your_form_data,
success: function() {
// where to redirect
location.href = '<?php echo url_for('route/toRedirectTo') ?>';
}
});
Look at:
Upvotes: 2