title: Javascript not working in JQuery loaded div?
body: <p>I load pages into a div. I can't execute javascript code in <code>page1.php</code>. How can I execute code when I load a page in to a div? Thanks for your help</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// &lt;![CDATA[
  function hide(id) {
    var divObject = document.getElementById(id);
    divObject.style.display = "none";
  }
  
  function show(id) {
      var divObject = document.getElementById(id);
      divObject.style.display = "block";
    }
    // ]]&gt;
    -- &gt;
    // &lt;![CDATA[
    function fthrkl() {
      var objemiz;
      /*@cc_on @*/
      /*@if (@_jscript_version &gt;= 5 ) try { objemiz = new ActiveXObject("Msxml2.XMLHTTP" ); } 
      catch (e ) { 
      try { objemiz = new ActiveXObject("Microsoft.XMLHTTP" ); } 
      catch (E ) { objemiz = false; } 
      }@end @*/
      if (!objemiz &amp;&amp; typeof XMLHttpRequest != 'undefined') {
        try {
          objemiz = new XMLHttpRequest();
        } catch (e) {
          objemiz = false;
        }
      }
      return objemiz;
    }
  
  function git(degerler, syf, alanadi) {
    gonder = new fthrkl();
    gonder.onreadystatechange = function() {
      document.getElementById(alanadi).innerHTML = "&lt;div class=yukle_pencere&gt;&lt;div class=yukle&gt;&lt;img src=images/load.gif align=center &gt;&lt;/div&gt;&lt;div class=yukle_yazi&gt;Yükleniyor&lt;/div&gt;&lt;/div&gt;";
      if (gonder.readyState == 4) {
        document.getElementById(alanadi).innerHTML = gonder.responseText;
  
        function fthrkl() {};
      }
    }
    gonder.open('GET', syf + '?' + degerler, true);
    gonder.send(null);
  }
  
  function git2(degerler2, syf2, alanadi2) {
    gonder2 = new fthrkl();
    gonder2.onreadystatechange = function() {
      document.getElementById(alanadi2).innerHTML = "&lt;center&gt;&lt;img src=/images/loading.gif border=0 align=center &gt;&lt;/center&gt;";
      if (gonder2.readyState == 4) {
        document.getElementById(alanadi2).innerHTML = gonder2.responseText;
  
        function fthrkl() {};
      }
    }
    gonder2.open('GET', syf2 + '?' + degerler2, true);
    gonder2.send(null);
    location.reload();
  }
  
  function git3(degerler3, syf3, alanadi3) {
    gonder3 = new fthrkl();
    gonder3.onreadystatechange = function() {
      document.getElementById(alanadi3).innerHTML = "&lt;center&gt;&lt;img src=/images/loading.gif border=0 align=center &gt;&lt;/center&gt;";
      if (gonder3.readyState == 4) {
        document.getElementById(alanadi3).innerHTML = gonder3.responseText;
  
        function fthrkl() {};
      }
    }
    gonder3.open('GET', syf3 + '?' + degerler3, true);
    gonder3.send(null);
  }
  
  function git5(degerler5, syf5, alanadi5) {
    gonder5 = new fthrkl();
    gonder5.onreadystatechange = function() {
      document.getElementById(alanadi5).innerHTML = "&lt;label class='control-label'&gt;Firma Ünvanı&lt;/label&gt;&lt;div class='controls'&gt;&lt;input type='text' class='input-xlarge' id='FirmaAdi' name='FirmaAdi' value='Firma Seçmediniz' disabled&gt;&lt;button class='btn' type='button'&gt;&lt;i class='icon-refresh'&gt;&lt;/i&gt; &lt;/button&gt;&lt;/div&gt;";
      if (gonder5.readyState == 4) {
        document.getElementById(alanadi5).innerHTML = gonder5.responseText;
  
        function fthrkl() {};
      }
    }
    gonder5.open('GET', syf5 + '?' + degerler5, true);
    gonder5.send(null);
  }
  
  function git4(degerler4, syf4, alanadi4) {
      gonder4 = new fthrkl();
      gonder4.onreadystatechange = function() {
        document.getElementById(alanadi4).innerHTML = "&lt;div class='alert alert-info'&gt;&lt;i class='fa fa-info-circle'&gt;&lt;/i&gt; Yükleniyor...&lt;/div&gt;";
        if (gonder4.readyState == 4) {
          document.getElementById(alanadi4).innerHTML = gonder4.responseText;
  
          function fthrkl() {};
        }
      }
      gonder4.open('GET', syf4 + '?' + degerler4, true);
      gonder4.send(null);
      location.reload();
    }
    // ]]&gt;
    -- &gt;</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#overlay {
    position: fixed;
    top: 0px;
    left: 0px;
    height: 100%;
    width: 100%;
    z-index: 9999999;
    background: url(../panel/img/popupb.png);
    display: none;
  }
  .pencere {
    position: absolute;
    width: 500px;
    margin: -100px 0px 0px -250px;
    top: 25%;
    left: 50%;
    text-align: left;
    padding: 0px;
    z-index: 99999999;
  }
  .pencere_ic {
    font-weight: normal;
    border-color: #01a161;
    background: #FFF;
    border-radius: 0px;
    padding: 0px;
    border-width: 3px 0px 0px 0px;
    border-top: 3px solid #01a161;
  }
  .yukle_pencere {
    margin: auto;
    width: 250px;
    height: 70px;
    background-color: white;
    font-weight: normal;
  }
  .yukle {
    text-align: center;
    padding: 10px;
    z-index: 9000;
  }
  .yukle_yazi {
    text-align: center;
    font-size: 13px;
    color: gray;
  }
  .yukle_pencere1 {
    margin-bottom: 18px;
    display: block;
  }
  .yukle1 {
    text-align: center;
    padding: 5px;
    z-index: 9000;
  }
  .yukle_yazi1 {
    text-align: center;
    font-size: 13px;
    color: green;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button type="submit" class="sppb-btn sppb-btn-primary" onclick="$('body').scrollTop(0);show('pencere');show('overlay');git('uid=666&amp;odemetur=0&amp;durum=0&amp;makbuz='+document.getElementById('makbuz').value+'&amp;tutar='+document.getElementById('tutar').value+'&amp;adne='+document.getElementById('adne').value+'&amp;OdemeYil='+document.getElementById('OdemeYil').value+'&amp;aciklama='+document.getElementById('aciklama').value+'&amp;OdemeAy='+document.getElementById('OdemeAy').value,'ajax/tahsilat.asp','pencere');"&gt;&lt;i class="fa"&gt;&lt;/i&gt; Gönder&lt;/button&gt;
  
  &lt;div class="pencere" id="pencere"&gt;&lt;/div&gt;
  &lt;div id="overlay"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thank you for your help</p>