title: Allowing javascripts in an AJAX Called file
body: <p>I have read numerous methods of allowing scripts that are called by an AJAX function but I am having trouble making it work, so if possible an example for this specific code would be great as I am relatively new to JS and AJAX.</p>
  
  <p><strong>This is the main javascript(which is looped in the index page) to request updated content</strong> 
  (Lets call this index.php)</p>
  
  <pre><code>if (window.XMLHttpRequest)
      xmlhttp2 = new XMLHttpRequest();
  } else {
      xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp2.onreadystatechange = function () {
      if (xmlhttp2.readyState == 4 &amp;&amp; xmlhttp2.status == 200) {
          document.getElementById("botcontain2").innerHTML = xmlhttp2.responseText;
      }
  }
  xmlhttp2.open("GET", "chat/shownew.php?fie=" + Math.random() + "&amp;id=" + id + "&amp;nm=" + nm, true);
  xmlhttp2.send();
  }
  </code></pre>
  
  <p><strong>Here is the javascript it will call in the shownew.php file which is meant to hook to the below form</strong></p>
  
  <pre><code>   &lt;script id=runscript2 type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/ext-core/3/ext-core.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" id="runscript"&gt;
          Ext.onReady(function(){
              Ext.fly('form').on('submit', function(e){
                  e.preventDefault();
              var date = Ext.fly('date').dom.value;
              var me = Ext.fly('me').dom.value;
              var them = Ext.fly('them').dom.value;
              var n = Ext.fly('text').dom.value;
              var hi = "submit.php?me="+me+"&amp;them="+them+"&amp;date="+date+"&amp;ty=ty";
                  Ext.Ajax.request({
                     url: "chat/insertchat.php?me="+me+"&amp;them="+them+"&amp;date="+date+"&amp;ty=ty",
                     success: function(){ alert(hi); },
                     failure: function() { alert(hi) ; }, 
              params: { text: n }
                  });
                  return false;               
              });         
          });     
      &lt;/script&gt;
  </code></pre>
  
  <p><strong>Yeh, its meant to hook onto this form in the same file that is called by ajax(shownew.php)</strong></p>
  
  <pre><code>    &lt;form id="form"&gt;
      &lt;input id="date" type="hidden" name="date"&gt;
      &lt;input id="me" type="hidden" name="me"&gt;
      &lt;input id="them" type="hidden" name="them"&gt;
      &lt;input id="text" type="text" name="text"&gt;
          &lt;input type="submit"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>So yeah, at the moment I can't get the shownew.php javascript to function at all.. any advice would be great, or a simple example on how I could make it work.</p>