title: Redirecting to route with parameters if response is success using Ajax and Laravel
body: <p>I created a form that register an order requested by the user logged in when he hits the submit button on the plan he chooses. It's working fine.
  But I want to redirect to checkout route for paying that order after the order is registered on database. I'm using ajax to validate inputs in client side.</p>
  <p><strong>My problem is that I don't know how to redirect it to a route with the plan parameter after the response is successful.</strong></p>
  <p>This is the route I want to redirect to:</p>
  <pre><code>{{ route('payments', ['plan' =&gt; $plan-&gt;identifier]) }}
  </code></pre>
  <p>Here's my validation on client side:</p>
  <pre><code>$(document).ready(function() {
      $(&quot;#btn-plan&quot;).click(function(e) {
          e.preventDefault();
  
          var _token = $(&quot;input[name='_token']&quot;).val();
          var app_name = $(&quot;input[name='app_name']&quot;).val();
          var domain = $(&quot;input[name='domain']&quot;).val();
          var new_domain = $(&quot;input[name='new_domain']&quot;).val();
          var alojamento = document.querySelector('input[name=&quot;alojamento&quot;]:checked').value;
          var criar_email = document.querySelector('input[name=&quot;criar_email&quot;]:checked').value;
          var facebook = $(&quot;input[name='facebook']&quot;).val();
          var instagram = $(&quot;input[name='instagram']&quot;).val();
          var linkedin = $(&quot;input[name='linkedin']&quot;).val();
          var categoria = document.querySelector('input[name=&quot;categoria&quot;]:checked').value;
          var contact = document.querySelector('input[name=&quot;contact&quot;]:checked').value;
  
          $.ajax({
              url: config.routes.zone,
              type: 'POST',
              data: { _token: _token, categoria: categoria, contact: contact, app_name: app_name, domain: domain, new_domain: new_domain, alojamento: alojamento, criar_email: criar_email, facebook: facebook, instagram: instagram, linkedin: linkedin },
              success: function(data) {
  
                  if ($.isEmptyObject(data.error)) {
  
                // It's supposed to be something here to redirect to the route
  
                  } else {
                      printErrorMsg(data.error);
                  }
              }
          });
      });
  
      function printErrorMsg(msg) {
          $(&quot;.print-error-msg&quot;).find(&quot;ul&quot;).html('');
          $(&quot;.print-error-msg&quot;).css('display', 'block');
          $.each(msg, function(key, value) {
              $(&quot;.print-error-msg&quot;).find(&quot;ul&quot;).append('&lt;li&gt;' + value + '&lt;/li&gt;');
          });
      }
  });
  </code></pre>