Send data to a controller via jquery with no return

Asked

Viewed 414 times

0

I’m working on a project in Laravel. In a certain part I need to send data to a controller via jquery and from the data obtained in the controller, redirect to another view. How can I do that? I usually use Ajax, but with it I think there is no way.

Ajax that I tried :

         $.ajax({
                url: "{{ URL::route('checkout.concluir') }}",
                type: "POST",
                data: {
                  forma_pagamento : forma_pagamento,
                  endereco_id : endereco_id,
                  frete : frete
                },
                cache: false,
                processData:true,
                success: function(data)
                {   
                  window.location.href = "{{ URL::route('checkout.concluir',  data ) }}";
                }
            });

         });

Controller return:

return View::make('frontend.checkout.concluido', $this->data);
  • Hello, have you tried console.log("{{ URL::route('checkout.conclude', data ) }}"); to check if the path is correct? I think what is window.location.assign("{{ URL::route('checkout.conclude', data ) }}")

  • A hint: It is not better to use an attribute data jQuery or a meta tag to do this? <meta name="laravel_route" content="{{ app('url')->route('minha.rota') }}">

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.