title: How do i make changes to an html element through jquery ajax permanent so it remains after refreshing the page?
body: <p>Im a beginner in codeigniter and am trying to make sort of an ecommerce website.</p>
  
  <p>Now whenever a user clicks on the "Add to cart" button in my view, i use jquery ajax to send a request to a controller function which returns two variables count(total items in cart) and total(the total value of items in cart) as a string and then i modify a div with class .cart to simply display a string containing the two variables.</p>
  
  <pre><code>$(document).ready(function(){
  
      $("#addtocart").click(function(){
  
  
      var id = $("#product_id").val();
      var qty = $("#quantity").val(); 
  
  $.ajax({
          url: "&lt;?php echo base_url('cart/addtocart'); ?&gt;",
          data: {id: id , qty:qty },
          type: 'POST',       
          success: function(name) {
  
              $(".cart").html(name); //This is the div where show number of items in cart and total value of cart
  
          }
      });
  
      });
  })
  </code></pre>
  
  <p>
  But the string doesnt remain when i refresh the page or go to another page. i want the change made through jquery permanent and remain their regardless where the user navigates in the website. I need direction on how to accomplish this. if i need to save it to my database, then what and how to go about it</p>