Jump to content

[SOLVED] AXAH - document.* help


MadnessRed

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/151851-solved-axah-document-help/
Share on other sites

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?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.