title: location.reload() in ajax for a button is messing with my jquery animation
body: <p>So I've a button which use ajax to send data to a php script. Also , I've a navigation bar whose background changes as I scroll down. The only problem here is that , once I have scrolled down to a point (after which the navigation bar background changes) and then I click the button. The location.reload() obviously refreshes the page , hence bringing back the original colour of the navigation bar.Not that the jQuery scroll-triggers-navigation-background change doesn't work after that, but still the page refresh reverts the background of the navigation bar to it's original state(which stays until I scroll again.)</p>
  
  <p>Here's my jQuery code for the nav bar:</p>
  
  <pre><code>    &lt;script&gt;
      $(document).ready(function(){
          $(window).scroll(function(){
              var scroll = $(window).scrollTop();
          console.log("Scroll at " + scroll);
          if (scroll &gt; 500) {
              $(".navbar").css("background" , "linear-gradient(to right,#4776E6 ,#8E54E9)");
          }
          else
          {
              $(".navbar").css("background" , "linear-gradient(to right, #434343 ,#000000 ,#434343)");
          }
          })
        })
  
      &lt;/script&gt;
  </code></pre>
  
  <p>The ajax code for the button :</p>
  
  <pre><code>cart.submit(function (e) {
  
          e.preventDefault();
  
          $("#add_to_cart").attr("disabled", true).val('Adding to Cart');
          $.ajax({
              type: cart.attr('method'), // POST or GET
              url: cart.attr('action'),   // THE PHP PAGE 
              data: cart.serialize(),
              success: function (data) {
                  if(data == "yes"){
                      alert("Event Added to Your Cart");
                      location.reload();
                  }
                  else{
                      alert(data);
                      $("#add_to_cart").attr("disabled", false).val('Participate');
                  }
              },
          });
  </code></pre>
  
  <p><a href="https://media.giphy.com/media/3o751P8TQKaKhRHPAA/giphy.gif" rel="nofollow noreferrer">Here's the link for the gif</a></p>