title: JavaScript not working inside AJAX loaded DIV
body: <p>I am having a problem getting the javascript code to work inside an AJAX loaded div, I am trying to include jquery tabs but it not working, the ajax outputs text only and won't recognize the javascript. Any help would be nice.</p>
  
  <p>Here is my js code:</p>
  
  <pre><code>var OpenedPage;
  
  function load(url, target) {
      document.getElementById(target).innerHTML = 'Loading ...';
      if (window.XMLHttpRequest) {
          req = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
          req = new ActiveXObject("Microsoft.XMLHTTP");
      }
      if (req != undefined) {
          req.onreadystatechange = function () {
              loadDone(url, target);
          };
          req.open("GET", url, true);
          req.send("");
      }
  }
  
  function loadDone(url, target) {
      if (req.readyState == 4) { // only if req is "loaded"
          if (req.status == 200) { // only if "OK"
              document.getElementById(target).innerHTML = "loaded" + req.responseText;
          } else {
              document.getElementById(target).innerHTML = "Error:\n" + req.status + "\n" + req.statusText;
          }
      }
  }
  
  function unload() {
      if (OpenedPage == "divsignin") {
          unloaddivsignin();
      }
      if (OpenedPage == "divHowto") {
          unloaddivHowto();
      }
  
  }
  
  function ShowHidedivsignin() {
      unload();
      OpenedPage = "divsignin";
      load("../slogin.php", "divsignin");
      $("#divsignin").animate({"height": "toggle"}, {duration: 800});
  }
  
  function unloaddivsignin() {
      OpenedPage = "";
      $("#divsignin").animate({"height": "toggle"}, {duration: 800});
  }
  
  function ShowHidedivHowto() {
      unload();
      OpenedPage = "divHowto";
      load("../howto.php", "divHowto");
      $("#divHowto").animate({"height": "toggle"}, {duration: 800});
  }
  
  function unloaddivHowto() {
      OpenedPage = "";
      $("#divHowto").animate({"height": "toggle"}, {duration: 800});
  }
  </code></pre>
  
  <p>And the HTML:</p>
  
  <pre><code>&lt;div id="divsignin" style="display:none;width:auto"&gt; &lt;/div&gt;
  
  
  &lt;a onClick="ShowHidedivHowto(); return false;" href="#"&gt;help&lt;/a&gt;
  </code></pre>