title: $_GET variable not staying set when set with ajax?
body: <p>sorry i am new to ajax and well programming in general.</p>
  
  <p>I have a set of divs each containing a set of products for an e-comm site. Only one div is visible at a time when a certain stock button is clicked. </p>
  
  <p>when a user clicks on a product displayed inside the visible div the user is taken to a new page where the product details are displayed. Basically What i'm trying to do is have a history when the user clicks the back button in the browser, i want it to return to the last div that was visible when the page is loaded.</p>
  
  <p>I am trying to use ajax to send a variable to a php file when the user opens a product div, and then retrieve that variable when the user clacks back and the  page reloads. I can send the variable fine with ajax to the php file and return with the success property of the same ajax function. But after that, when i try to retrieve the variable, it appears as unset.</p>
  
  <p><strong>Ajax send method:</strong></p>
  
  <pre><code>    // when the user clicks the apparel stock button the corresponding div becomes visible 
      $("#stockApparel").click(function(){
  
        var $apparel = "apparel";
  
        $.ajax({
  
            url: "php/panel.php",
  
            data: { panel: $apparel },
  
            type: "get",
  
            dataType: "text",
  
            success: function(response){
                alert(response); // response is "apparel" as intended/
            },
  
        });
  
  
        $("#stockButtons").animate({left: '1140px'});
        $("#new").animate({left: '-470px'});
        $("#apparel").show(700);
        $("#marketing").hide(100);
  
        var divPosition = $('#shippingImg').offset();
        $('html, body').animate({scrollTop: divPosition.top}, "slow");
  
    });
  </code></pre>
  
  <p><strong>Get method to retrieve variable</strong></p>
  
  <pre><code>$(window).load(function(){
           alert('window has been fully loaded');
  
          $.get("php/panel.php", function(data, status){
              alert("Data: " + data + "\nStatus: " + status); // returns as "variable not set".
          });
  
       });
  </code></pre>
  
  <p><strong>Php file</strong></p>
  
  <pre><code>if (isset($_GET['panel'])) { // check if varaiable has been set
  
      $panel  = $_GET['panel'];
      switch ($panel) {
          case "collectable":
              echo "collectable";
          break;
  
         case "apparel":
             echo "apparel";
         break;
  
         default:
      }
   } else echo "Variable not set."; // if variable is not set
  
  ?&gt;
  </code></pre>
  
  <p>even if i put the $.get method directly after the ajax send method i still get the "Variable not set" returned from the php file, any ideas what im doing wrong?</p>