title: How to trigger change when using the back button with history.pushstate and popstate?
body: <p>I'm pretty much a novice when it comes to js so I'm sorry if I'm missing something really simple.</p>
  
  <p>Basically, I've done some research into using the history.pustate and popstate and I've made it so a query string is added to the end of the url (<code>?v=images</code>) or (<code>?v=profile</code>)...(<code>v</code> meaning 'view') by using this:</p>
  
  <pre><code>var url = "?v=profile"
  var stateObj = { path: url };
  history.pushState(stateObj, "page 2", url);
  </code></pre>
  
  <p>I want to make it so I can load content into a div but without reloading the page which I have done using the <code>.load()</code> function. </p>
  
  <p>I then used this code:</p>
  
  <pre><code>$(window).bind('popstate', function(event) {
      var state = event.originalEvent.state;
  </code></pre>
  
  <p>in <code>$(document).ready()</code> section and later tried within just <code>&lt;script&gt;</code> tags and neither worked. </p>
  
  <p>I don't know how to make it so the content changes when I use the back button or at least makes it so I can trigger my own function to do so; and I'm assuming it has something to do with the state object?! I just can't seem to find anything online that explains the process clearly.</p>
  
  <p>If someone could help me out it would be amazing and thank you in advance to anyone who does!</p>