php - Allowing javascripts in an AJAX Called file -


i have read numerous methods of allowing scripts called ajax function having trouble making work, if possible example specific code great relatively new js , ajax.

this main javascript(which looped in index page) request updated content (lets call index.php)

if (window.xmlhttprequest)     xmlhttp2 = new xmlhttprequest(); } else {     xmlhttp2 = new activexobject("microsoft.xmlhttp"); } xmlhttp2.onreadystatechange = function () {     if (xmlhttp2.readystate == 4 && xmlhttp2.status == 200) {         document.getelementbyid("botcontain2").innerhtml = xmlhttp2.responsetext;     } } xmlhttp2.open("get", "chat/shownew.php?fie=" + math.random() + "&id=" + id + "&nm=" + nm, true); xmlhttp2.send(); } 

here javascript call in shownew.php file meant hook below form

   <script id=runscript2 type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/ext-core/3/ext-core.js"></script>     <script type="text/javascript" id="runscript">         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+"&them="+them+"&date="+date+"&ty=ty";                 ext.ajax.request({                    url: "chat/insertchat.php?me="+me+"&them="+them+"&date="+date+"&ty=ty",                    success: function(){ alert(hi); },                    failure: function() { alert(hi) ; },              params: { text: n }                 });                 return false;                            });                  });          </script> 

yeh, meant hook onto form in same file called ajax(shownew.php)

    <form id="form">     <input id="date" type="hidden" name="date">     <input id="me" type="hidden" name="me">     <input id="them" type="hidden" name="them">     <input id="text" type="text" name="text">         <input type="submit">     </form> 

so yeah, @ moment can't shownew.php javascript function @ all.. advice great, or simple example on how make work.

script tags loaded through xmlhttprequest not evaluated. can said go in number of directions. use image hack , define function in parent file make ajax call.

you use eval(), although no 1 ever should if there solution.

append script in parent document.

or use jquery might easiest way.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -