dreamwest Posted January 9, 2011 Share Posted January 9, 2011 So ive called a page with ajax but the called page's javascript doesnt work, what am i missing?? main.html <script> function Data($Request, $Control, $jump, $player) { if($jump){ window.location = String(window.location).replace(/\#.*$/, "") + "#top"; } if($player){ document.getElementById("more").style.display = "block"; } if ($Control == "" || $Control == null) {alert ("No output specified !"); return;} var ai = new AJAXInteraction($Request, GetServerData, $Control ); ai.doGet(); } function GetServerData ($TheData, $Control){ document.getElementById($Control).innerHTML = $TheData; } function AJAXInteraction(url, callback, $Control) { var req = init(); req.onreadystatechange = processRequest; function init() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else {alert ("Your browser seems to be out of date, Please update!"); return; } } function processRequest () { if (req.readyState == 4) { if (req.status == 200) callback(req.responseText, $Control); } else callback(Myvar , $Control); } this.doGet = function() { req.open("GET", url, true); req.send(null); } } </script> <span onclick='Data("/page.html", "T"); return false;'>Click</span> <ul id='T'></ul> page.html <script src='/jquery_tools.js'></script> ..javascript stuff here Link to comment https://forums.phpfreaks.com/topic/223848-javascript-and-ajax/ Share on other sites More sharing options...
haku Posted January 9, 2011 Share Posted January 9, 2011 You haven't shown enough info here. What is the code that is not being executed? Link to comment https://forums.phpfreaks.com/topic/223848-javascript-and-ajax/#findComment-1156991 Share on other sites More sharing options...
dreamwest Posted January 9, 2011 Author Share Posted January 9, 2011 Ok this i everthing relevant ajax.js function Data($Request, $Control, $jump, $player) { if($jump){ window.location = String(window.location).replace(/\#.*$/, "") + "#top"; } if($player){ document.getElementById("more").style.display = "block"; } if ($Control == "" || $Control == null) {alert ("No output specified !"); return;} var ai = new AJAXInteraction($Request, GetServerData, $Control ); ai.doGet(); } function GetServerData ($TheData, $Control){ document.getElementById($Control).innerHTML = $TheData; } function AJAXInteraction(url, callback, $Control) { var req = init(); req.onreadystatechange = processRequest; function init() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else {alert ("Your browser seems to be out of date, Please update!"); return; } } function processRequest () { if (req.readyState == 4) { if (req.status == 200) callback(req.responseText, $Control); } else callback(Myvar , $Control); } this.doGet = function() { req.open("GET", url, true); req.send(null); } } main.html <script src="/ajax.js"></script> <span onclick='Data("/page.html", "T"); return false;'>Click</span> <ul id='T'></ul> page.html <script src="/ajax.js"></script> <span onclick='Data("/test.html", "T"); return false;'>Click</span> test.html page.html has initiated this page So the javascrpt in page.html isnt getting initiated Link to comment https://forums.phpfreaks.com/topic/223848-javascript-and-ajax/#findComment-1157196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.