title: Laravel - ajax post and go to another view with data
body: <p>I´ve searching but with no luck, i´ve tried implementing many things but nothing lead to success, so this is my scenario:</p>
  
  <p>At certain point the user is in a view where after filling some fields, he has the ability to <strong>save</strong> or <strong>save and create</strong>. </p>
  
  <p>The first one it is working ok, i´m posting with ajax to my controller method and returning a json response, but the user stays normally in the same view.</p>
  
  <p>The second one(when he saves and create) i´m sending a variable to say exactly that, and because of that choice, <strong>the user must be directed to another view to "create" BUT i need the data that was previously saved to automatically fill some fields on the new form</strong> that is suppose to be created...so my code is:</p>
  
  <p><strong>my ajax:</strong></p>
  
  <pre><code>$.ajax({
       method: 'POST',
       url: '/Cliente/insertEditCliente',
       dataType: "json",
       data: {"_token": "{{ csrf_token()}}", "mainId":$('#mainId').val(),values,"btnId":this.text},
       success: function(response){
          if(response.titulo != "Erro!"){
            let dados = response['dados'];
            window.location = '{{ route("formAngariacao",[null]) }}'+'/?dados='+dados;
                      }
                  },
                  error: function(jqXHR, textStatus, errorThrown) { // What to do if we fail
                      // console.log(JSON.stringify(jqXHR));
                      // console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
                  }
              });
  </code></pre>
  
  <p><strong>in my controller method, i have that if statment to detect if it was just save or save and create:</strong></p>
  
  <pre><code>if($request-&gt;post('btnId') == "Guardar"){
                  return response()-&gt;json(["titulo"=&gt;"Ok!","mensagem"=&gt;"Cliente Alterado com sucesso!","tipo"=&gt;"success"]);
              }
              else{
                  return response()-&gt;json(["titulo"=&gt;"Ok!","mensagem"=&gt;"Cliente Alterado com sucesso!","tipo"=&gt;"success","dados"=&gt;$request]);
              }
  </code></pre>
  
  <p>But now, in my blade view, i <strong>need to read that array "dados"</strong> which corresponds to the $request variable and has all the data i need.</p>
  
  <p><strong>How do i do that? and is this the best practice?</strong> </p>
  
  <p>thanks for your time reagards.</p>