title: Update session variable when form is submited. AJAX. Laravel
body: <p>What I want to do is when I submit my form with ticket code the variables should update without page refresh. What I only achieve now is submit form without page refresh and it works. And if I submit form and then refresh page manually the variables change, but then again I can submit the same form. So I want to prevent that. This is my form:</p>
  
  <p><code>Form</code></p>
  
  <pre><code> &lt;form id="ticket" action="prekiu-uzsakymas" method="get"&gt;
                          &lt;input type="text" name="ticket"&gt;
                          &lt;input id="btnSubmit" type="submit" value="Panaudoti kuponą"&gt;
                      &lt;/form&gt;
  </code></pre>
  
  <p>This is my <code>AJAX</code>:</p>
  
  <pre><code>$(document).ready(function(){
  
              $('#ticket').on('submit',function(e){
                  $.ajaxSetup({
                      headers: {
                          'X-CSRF-Token': $('meta[name="csrf_token"]').attr('content')
                      }
                  });
                  e.preventDefault(e);
  
  
                  $.ajax({
  
                      method:"GET",
                      url: $("#ticket").attr("action"),
                      data:$(this).serialize(),
                      dataType: 'html',
                      success: function(data) {
                          var statusHTML = '&lt;h4&gt;&lt;span class="label label-success"&gt;' +
                                  '&lt;i style="color: white" class="glyphicon glyphicon-ok"&gt;&lt;/i&gt; Ticket used successfuly.&lt;/span&gt;&lt;/h4&gt;&lt;br&gt;';
  
                          $("#ticket").replaceWith(statusHTML);
                      },
                      error:function(data){
                          console.log("request failed");
                      }
                  })
  
              });
  
          });
  </code></pre>
  
  <p>This is what executes when I submit form with page refresh:</p>
  
  <pre><code>foreach ($products as &amp;$item) {
                      $item['price'] = $item['price'] - ($item['price'] * ($ticket-&gt;discount / 100));
                  }
  
                  Session::put('cart', $products);
  </code></pre>
  
  <p>It all works but I don't know how to update values without page refresh so the user can see and cannot submit the form second time. </p>