MadnessRed Posted March 31, 2009 Share Posted March 31, 2009 Hi, I have a page which I am loading via AXAH, I am not sure weather this should be in AJAX or javascript so please forgive me if I am wrong. Anyway this page I have loaded, I want it to edit the title of the page that is loading it. I am loading this javascript file. //object detection to return the correct object depending upon broswer type. Used by the getAXHA(); function. function getNewHttpObject() { var objType = false; try { objType = new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) { try { objType = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { objType = new XMLHttpRequest(); } } return objType; } //Function used to update page content with new xhtml fragments by using a javascript object, the dom, and http. function getAXAH(url,elementContainer){ document.getElementById(elementContainer).innerHTML = '<blink class="redtxt">Loading...<\/blink>'; var theHttpRequest = getNewHttpObject(); theHttpRequest.onreadystatechange = function() {processAXAH(elementContainer);}; theHttpRequest.open("GET", url); theHttpRequest.send(false); function processAXAH(elementContainer){ if (theHttpRequest.readyState == 4) { if (theHttpRequest.status == 200) { document.getElementById(elementContainer).innerHTML = theHttpRequest.responseText; } else { document.getElementById(elementContainer).innerHTML="<p><span class='redtxt'>Error!<\/span> HTTP request return the following status message: " + theHttpRequest.statusText +"<\/p>"; } } } } That then loads a page into a div. Now that page reads the following <script language="javascript"> document.title = "Loaded page"; </script> Loading this page, the title should change. The problem is that this isn't changing the page title. Any ideas why? I am very new to the A*A* stuff. Quote Link to comment https://forums.phpfreaks.com/topic/151851-solved-axah-document-help/ Share on other sites More sharing options...
corbin Posted March 31, 2009 Share Posted March 31, 2009 The AJAX object does not parse JavaScript. You will either need to extract data in <script> tags and eval() it, or you can use a framework such as jQuery that has the ability to parse JS in a response built into it. Quote Link to comment https://forums.phpfreaks.com/topic/151851-solved-axah-document-help/#findComment-797402 Share on other sites More sharing options...
MadnessRed Posted March 31, 2009 Author Share Posted March 31, 2009 The AJAX object does not parse JavaScript. You will either need to extract data in <script> tags and eval() it, or you can use a framework such as jQuery that has the ability to parse JS in a response built into it. ok thanks, what I have done is I have a function in the mainy file called update() and then I am running that from the file I load. atm I have this echo '<a onclick="update(\''.$title.'\');" href="#">Click me to update</a>'; I don't suppose there is an equivalent to <body onload=""> is there? Quote Link to comment https://forums.phpfreaks.com/topic/151851-solved-axah-document-help/#findComment-797408 Share on other sites More sharing options...
corbin Posted March 31, 2009 Share Posted March 31, 2009 document.onload = function; Quote Link to comment https://forums.phpfreaks.com/topic/151851-solved-axah-document-help/#findComment-797420 Share on other sites More sharing options...
MadnessRed Posted March 31, 2009 Author Share Posted March 31, 2009 document.onload = function; ok, many thanks, ill try that now. Quote Link to comment https://forums.phpfreaks.com/topic/151851-solved-axah-document-help/#findComment-797674 Share on other sites More sharing options...
MadnessRed Posted March 31, 2009 Author Share Posted March 31, 2009 document.onload = function; ok, many thanks, ill try that now. hi sorry, where exactly should I put that script? should I say the the top of the file: echo '<script language="javascript">document.onload = update(\''.$title.'\');</script>'; Quote Link to comment https://forums.phpfreaks.com/topic/151851-solved-axah-document-help/#findComment-797685 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.