title: Ajax call to Server PHP only sometimes print back request
body: <p>When I load my index.html site, it would sometimes return the Ajax which would call the php on server to print the result of my dynamic page. Why does it only sometimes work when I go to the address bar and press enter or refresh?</p>
  
  <p>This is the site <a href="http://cis-linux2.temple.edu/~tud15304/secretSanta/" rel="nofollow">Click Here!</a></p>
  
  <p>This has been bothering me for sometime now.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;title&gt;Christmas- 2014: Secret Santa&lt;/title&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;link rel="stylesheet" type="text/css" href="css/styleSheet.css"&gt;
    &lt;link rel="icon" type="icon" href="images/favicon.ico"&gt;
  
    &lt;script&gt;
      var xmlhttp;
      if (window.XMLHttpRequest) {
        //code for IE7, Firefox and everything new....
        xmlhttp = new XMLHttpRequest();
      } else {
        //for the old things
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
  
  
  
  
      xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
          document.getElementById("mainDynamic").innerHTML = xmlhttp.responseText;
        }
  
  
  
  
  
        $(document).ready(function() {
          $("#export_excel_button").click(function(e) {
  
            window.open('data:application/vnd.ms-excel,' + $('#userTable').html());
            e.preventDefault();
          });
  
        });
  
  
      }
  
      xmlhttp.open("GET", "resourceLines.php", true);
      xmlhttp.send();
    &lt;/script&gt;
    &lt;script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
    &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body id='mainBody'&gt;
    &lt;img class="Banner" src="images/Banner.JPG" alt="Banner" width="886" height="187"&gt;
    &lt;section&gt;
      &lt;div id='mainDynamic'&gt;
  
  
      &lt;/div&gt;
      &lt;article class='leftSide'&gt;
        &lt;div class="Presentations"&gt;
          &lt;h1&gt;Important Information&lt;/h1&gt;
          &lt;b&gt;WebSite Scheme:&lt;/b&gt;
          &lt;br&gt;
          &lt;p&gt;The Purpose of this is to have computer generated randomization of the "Secret Santa gifting". All wish list can be made online and will be automatically uploaded to the server. Then, I will run the program to randomly pair you then display the
            wish list to whom you'll be a secret Santa to.&lt;/p&gt;
  
          &lt;p&gt;So things to do:
            &lt;p&gt;
              &lt;ul&gt;
                &lt;li&gt;Make an account&lt;/li&gt;
                &lt;li&gt;Build your wish list&lt;/li&gt;
              &lt;/ul&gt;
              &lt;p&gt;&lt;b&gt;WARNING&lt;/b&gt;: It is important that you make only ONE! account for yourself.
                &lt;p&gt;
  
                  &lt;p&gt;
                    &lt;b&gt;Gifting Criteria:&lt;/b&gt;
                    &lt;br&gt;
  
                    &lt;ul&gt;
                      &lt;li&gt;&lt;b&gt;Amount of Gifts-&lt;/b&gt; Each person should have at least 3 gifts for the gift-er to chose from&lt;/li&gt;
                      &lt;li&gt;&lt;b&gt;Price of Total Gifts-&lt;/b&gt; $50&lt;/li&gt;
                      &lt;li&gt;Total Amount of gifts you buy for the person must be close to equal or more than $50&lt;/li&gt;
                    &lt;/ul&gt;
                    &lt;br&gt;
                    &lt;b&gt;Commonly Asked Questions&lt;/b&gt;
                    &lt;ul&gt;
                      &lt;li&gt;Can we list multiple gifts on our wish list to add up to the &lt;b&gt;MAX&lt;/b&gt; dollar amount? Yes, if there are multiple low priced items, you will have to chose to buy enough gifts to add up to the total amount.&lt;/li&gt;
                    &lt;/ul&gt;
                  &lt;/p&gt;
        &lt;/div&gt;
      &lt;/article&gt;
    &lt;/section&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>